diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cde12894ac4000b3944e2d7e6099c30104849c83..0fa450c46c763c54153855a1733a1e92690933b3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,6 +20,7 @@ test_api:
     paths:
       - "$PIP_CACHE_DIR"
   variables:
+    DJANGO_ALLOWED_HOSTS: "localhost"
     DATABASE_URL: "postgresql://postgres@postgres/postgres"
 
   before_script:
diff --git a/api/config/settings/common.py b/api/config/settings/common.py
index 9e17267bb98cfd06ec4cadaa08370641126275c8..6d02cbbc1038999cc7a3de46448369aa00e030bf 100644
--- a/api/config/settings/common.py
+++ b/api/config/settings/common.py
@@ -23,6 +23,10 @@ try:
     env.read_env(ROOT_DIR.file('.env'))
 except FileNotFoundError:
     pass
+
+ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS')
+
+
 # APP CONFIGURATION
 # ------------------------------------------------------------------------------
 DJANGO_APPS = (
diff --git a/api/config/settings/production.py b/api/config/settings/production.py
index e009833050ead06ea7d62089f4c8182b3bbd172c..df15d325f22d8d78616c937a3142b4a11b34ded8 100644
--- a/api/config/settings/production.py
+++ b/api/config/settings/production.py
@@ -54,7 +54,6 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
 # ------------------------------------------------------------------------------
 # Hosts/domain names that are valid for this site
 # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS')
 CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS
 
 # END SITE CONFIGURATION
diff --git a/api/test.yml b/api/test.yml
index c59ce45bbbbaf2357a2b50782bc004f51b584cce..e892dfb178221ccd5ba8ed83558f3a6436b20dad 100644
--- a/api/test.yml
+++ b/api/test.yml
@@ -10,6 +10,7 @@ services:
     volumes:
       - .:/app
     environment:
+      - "DJANGO_ALLOWED_HOSTS=localhost"
       - "DATABASE_URL=postgresql://postgres@postgres/postgres"
   postgres:
     image: postgres