From 73f479d5db39868928697ab92680b244ff8923f2 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 3 Jan 2023 14:41:26 +0100 Subject: [PATCH 1/2] Ensure that '*' or 'localhost' is always in ALLOWED_HOSTS --- configuration/configuration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configuration/configuration.py b/configuration/configuration.py index 8d19fd9..db35c1b 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -58,6 +58,9 @@ _BASE_DIR = dirname(dirname(abspath(__file__))) # # Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local'] ALLOWED_HOSTS = environ.get('ALLOWED_HOSTS', '*').split(' ') +# ensure that '*' or 'localhost' is always in ALLOWED_HOSTS +if '*' not in ALLOWED_HOSTS and 'localhost' not in ALLOWED_HOSTS: + ALLOWED_HOSTS.append('localhost') # PostgreSQL database configuration. See the Django documentation for a complete list of available parameters: # https://docs.djangoproject.com/en/stable/ref/settings/#databases From 7e0a8fee82d064874784ba707971f2aeea3d5a7a Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 3 Jan 2023 16:48:00 +0100 Subject: [PATCH 2/2] Improved comment --- configuration/configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/configuration.py b/configuration/configuration.py index db35c1b..cff152f 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -58,7 +58,7 @@ _BASE_DIR = dirname(dirname(abspath(__file__))) # # Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local'] ALLOWED_HOSTS = environ.get('ALLOWED_HOSTS', '*').split(' ') -# ensure that '*' or 'localhost' is always in ALLOWED_HOSTS +# ensure that '*' or 'localhost' is always in ALLOWED_HOSTS (needed for health checks) if '*' not in ALLOWED_HOSTS and 'localhost' not in ALLOWED_HOSTS: ALLOWED_HOSTS.append('localhost')