From 409b076c237cf8f9ad31f5a0a74b6fd98e5377c4 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 25 Nov 2018 18:40:56 +0100
Subject: [PATCH] Removed the need to specify the DJANGO_ALLOWED_HOSTS variable

---
 .gitlab-ci.yml                                | 1 -
 api/config/settings/common.py                 | 2 +-
 changes/changelog.d/allowed-hosts.enhancement | 1 +
 demo/env.sample                               | 1 -
 deploy/env.prod.sample                        | 6 ------
 5 files changed, 2 insertions(+), 9 deletions(-)
 create mode 100644 changes/changelog.d/allowed-hosts.enhancement

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 18b00cab..76500e4b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -140,7 +140,6 @@ test_api:
     paths:
       - "$PIP_CACHE_DIR"
   variables:
-    DJANGO_ALLOWED_HOSTS: "localhost"
     DATABASE_URL: "postgresql://postgres@postgres/postgres"
     FUNKWHALE_URL: "https://funkwhale.ci"
     DJANGO_SETTINGS_MODULE: config.settings.local
diff --git a/api/config/settings/common.py b/api/config/settings/common.py
index a445e102..cd1b3208 100644
--- a/api/config/settings/common.py
+++ b/api/config/settings/common.py
@@ -60,7 +60,7 @@ FEDERATION_MUSIC_NEEDS_APPROVAL = env.bool(
 )
 # XXX: deprecated, see #186
 FEDERATION_ACTOR_FETCH_DELAY = env.int("FEDERATION_ACTOR_FETCH_DELAY", default=60 * 12)
-ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")
+ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=[]) + [FUNKWHALE_HOSTNAME]
 
 # APP CONFIGURATION
 # ------------------------------------------------------------------------------
diff --git a/changes/changelog.d/allowed-hosts.enhancement b/changes/changelog.d/allowed-hosts.enhancement
new file mode 100644
index 00000000..bd52e25f
--- /dev/null
+++ b/changes/changelog.d/allowed-hosts.enhancement
@@ -0,0 +1 @@
+Removed the need to specify the DJANGO_ALLOWED_HOSTS variable
diff --git a/demo/env.sample b/demo/env.sample
index 0c966876..a41eee2b 100644
--- a/demo/env.sample
+++ b/demo/env.sample
@@ -1,5 +1,4 @@
 FUNKWHALE_URL=https://demo.funkwhale.audio/
-DJANGO_ALLOWED_HOSTS=demo.funkwhale.audio
 FUNKWHALE_API_PORT=5001
 DJANGO_SECRET_KEY=demo
 DATABASE_URL=postgresql://postgres@postgres/postgres
diff --git a/deploy/env.prod.sample b/deploy/env.prod.sample
index 3918f95e..fe4fe555 100644
--- a/deploy/env.prod.sample
+++ b/deploy/env.prod.sample
@@ -4,7 +4,6 @@
 # If you're tweaking this file from the template, ensure you edit at least the
 # following variables:
 # - DJANGO_SECRET_KEY
-# - DJANGO_ALLOWED_HOSTS
 # - FUNKWHALE_HOSTNAME
 # - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails)
 # On non-docker setup **only**, you'll also have to tweak/uncomment those variables:
@@ -85,11 +84,6 @@ MEDIA_ROOT=/srv/funkwhale/data/media
 # (Ensure this directory actually exists)
 STATIC_ROOT=/srv/funkwhale/data/static
 
-# Update it to match the domain that will be used to reach your funkwhale
-# instance
-# Example: DJANGO_ALLOWED_HOSTS=funkwhale.yourdomain.com
-DJANGO_ALLOWED_HOSTS=yourdomain
-
 # which settings module should django use?
 # You don't have to touch this unless you really know what you're doing
 DJANGO_SETTINGS_MODULE=config.settings.production
-- 
GitLab