From 02f64aef12da34c1cb2d804a644f8e15a4bad889 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 21 Aug 2020 13:32:09 +0200 Subject: [PATCH] Use local hosts only when debug is enabled --- blog/settings.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/blog/settings.py b/blog/settings.py index 8fc3b40..4e0218d 100644 --- a/blog/settings.py +++ b/blog/settings.py @@ -45,13 +45,13 @@ EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend" DEBUG = os.getenv("DEBUG", "true").lower() == "true" TESTING = os.getenv("TESTING", "false").lower() == "true" -ALLOWED_HOSTS = [ - "localhost", - "127.0.0.1", -] -HOST = os.getenv("HOST") -if HOST: - ALLOWED_HOSTS.append(HOST) +ALLOWED_HOSTS = [] +if DEBUG: + ALLOWED_HOSTS.extend(["localhost", "127.0.0.1"]) + +HOSTS = os.getenv("HOSTS") +if HOSTS: + ALLOWED_HOSTS.extend(HOSTS.split(";")) # Application definition