2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Tweaks for SITE_URL setup (#6602)

This commit is contained in:
Oliver 2024-02-28 22:54:07 +11:00 committed by GitHub
parent b192c44b61
commit bf97804a0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -994,6 +994,9 @@ ALLOWED_HOSTS = get_setting(
typecast=list, typecast=list,
) )
if SITE_URL and SITE_URL not in ALLOWED_HOSTS:
ALLOWED_HOSTS.append(SITE_URL)
# List of trusted origins for unsafe requests # List of trusted origins for unsafe requests
# Ref: https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-trusted-origins # Ref: https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-trusted-origins
CSRF_TRUSTED_ORIGINS = get_setting( CSRF_TRUSTED_ORIGINS = get_setting(
@ -1004,7 +1007,7 @@ CSRF_TRUSTED_ORIGINS = get_setting(
) )
# If a list of trusted is not specified, but a site URL has been specified, use that # If a list of trusted is not specified, but a site URL has been specified, use that
if SITE_URL and len(CSRF_TRUSTED_ORIGINS) == 0: if SITE_URL and SITE_URL not in CSRF_TRUSTED_ORIGINS:
CSRF_TRUSTED_ORIGINS.append(SITE_URL) CSRF_TRUSTED_ORIGINS.append(SITE_URL)
USE_X_FORWARDED_HOST = get_boolean_setting( USE_X_FORWARDED_HOST = get_boolean_setting(
@ -1045,7 +1048,7 @@ CORS_ALLOWED_ORIGINS = get_setting(
) )
# If no CORS origins are specified, but a site URL has been specified, use that # If no CORS origins are specified, but a site URL has been specified, use that
if SITE_URL and len(CORS_ALLOWED_ORIGINS) == 0: if SITE_URL and SITE_URL not in CORS_ALLOWED_ORIGINS:
CORS_ALLOWED_ORIGINS.append(SITE_URL) CORS_ALLOWED_ORIGINS.append(SITE_URL)
for app in SOCIAL_BACKENDS: for app in SOCIAL_BACKENDS: