From 2ab2064a72ca9ebb840c0dcd1627502e4d6fcaa1 Mon Sep 17 00:00:00 2001 From: Will Ho Date: Fri, 28 Apr 2023 02:08:55 +0800 Subject: [PATCH] Fix ALLOWED_HOSTS logic being overwritten when * is set --- src/paperless/settings.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 0301fffad..ce498ec58 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -422,11 +422,12 @@ if _paperless_url: _paperless_uri = urlparse(_paperless_url) CSRF_TRUSTED_ORIGINS.append(_paperless_url) CORS_ALLOWED_ORIGINS.append(_paperless_url) - if ["*"] != ALLOWED_HOSTS: + +if ["*"] != ALLOWED_HOSTS: + # always allow localhost. Necessary e.g. for healthcheck in docker. + ALLOWED_HOSTS.append(["localhost"]) + if _paperless_url: ALLOWED_HOSTS.append(_paperless_uri.hostname) - else: - # always allow localhost. Necessary e.g. for healthcheck in docker. - ALLOWED_HOSTS = [_paperless_uri.hostname] + ["localhost"] # For use with trusted proxies TRUSTED_PROXIES = __get_list("PAPERLESS_TRUSTED_PROXIES")