diff --git a/bookmarks/settings/base.py b/bookmarks/settings/base.py index 44f8813..f73d34d 100644 --- a/bookmarks/settings/base.py +++ b/bookmarks/settings/base.py @@ -29,6 +29,13 @@ DEBUG = False ALLOWED_HOSTS = ["*"] +USE_X_FORWARDED_HOST = os.getenv("LD_USE_X_FORWARDED_HOST", False) in ( + True, + "True", + "true", + "1", +) + # Application definition INSTALLED_APPS = [ @@ -217,16 +224,6 @@ if LD_ENABLE_AUTH_PROXY: if LD_AUTH_PROXY_LOGOUT_URL: LOGOUT_REDIRECT_URL = LD_AUTH_PROXY_LOGOUT_URL -LD_USE_X_FORWARDED_HOST = os.getenv("LD_USE_X_FORWARDED_HOST", False) in ( - True, - "True", - "true", - "1", -) - -if LD_USE_X_FORWARDED_HOST: - USE_X_FORWARDED_HOST = LD_USE_X_FORWARDED_HOST - # CSRF trusted origins trusted_origins = os.getenv("LD_CSRF_TRUSTED_ORIGINS", "") if trusted_origins: diff --git a/docs/src/content/docs/options.md b/docs/src/content/docs/options.md index f1e4bda..5bc09a7 100644 --- a/docs/src/content/docs/options.md +++ b/docs/src/content/docs/options.md @@ -200,7 +200,7 @@ Values: `true` or `false` | Default = `false` If enabled the server will trust the `X-Forwarded-Host` header over the `Host` header to determine the hostname of the server. This should only be enabled if a proxy which sets this header is in use. -This setting is adopted from the Django framework used by linkding, more information on the setting is available in the [Django documentation](https://docs.djangoproject.com/en/6.0/ref/settings/#std-setting-USE_X_FORWARDED_HOST) +This setting is adopted from the Django framework used by linkding, more information on the setting is available in the [Django documentation](https://docs.djangoproject.com/en/6.0/ref/settings/#std-setting-USE_X_FORWARDED_HOST). ### `LD_LOG_X_FORWARDED_FOR`