Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix ALLOWED_HOSTS logic being overwritten when * is set

Will Ho2ab2064a72ca
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")