]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix ALLOWED_HOSTS logic being overwritten when * is set
authorWill Ho <will.ho@grabtaxi.com>
Thu, 27 Apr 2023 18:08:55 +0000 (02:08 +0800)
committerWill Ho <will.ho@grabtaxi.com>
Thu, 27 Apr 2023 18:08:55 +0000 (02:08 +0800)
src/paperless/settings.py

index 0301fffad555577859a97837d9474db85443f618..ce498ec58aa63ced56f34d8c8d2ce9784404dd00 100644 (file)
@@ -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")