From 2f8a026afa15a4a1d92cdad89852f00fe0fbca74 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 18 Feb 2018 14:28:44 +0100
Subject: [PATCH] Can now configure allowed host in all settings

---
 .gitlab-ci.yml                    | 1 +
 api/config/settings/common.py     | 4 ++++
 api/config/settings/production.py | 1 -
 api/test.yml                      | 1 +
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cde12894..0fa450c4 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 9e17267b..6d02cbbc 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 e0098330..df15d325 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 c59ce45b..e892dfb1 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
-- 
GitLab