settings: Allow customization of STATIC_URL.

Some requests will still be to `/static/`, either at the realm's
domain, or at the root domain.
This commit is contained in:
Alex Vandiver 2023-01-24 22:44:06 +00:00 committed by Alex Vandiver
parent dd21e472e7
commit 3559bf416d
4 changed files with 10 additions and 4 deletions

View File

@ -56,6 +56,7 @@ def is_root_domain_available() -> bool:
def is_static_or_current_realm_url(url: str, realm: Optional[Realm]) -> bool:
assert settings.STATIC_URL is not None
split_url = urllib.parse.urlsplit(url)
split_static_url = urllib.parse.urlsplit(settings.STATIC_URL)

View File

@ -60,6 +60,7 @@ from .configured_settings import (
SOCIAL_AUTH_SAML_ENABLED_IDPS,
SOCIAL_AUTH_SAML_SECURITY_CONFIG,
SOCIAL_AUTH_SUBDOMAIN,
STATIC_URL,
STATSD_HOST,
TORNADO_PORTS,
USING_PGROONGA,
@ -537,9 +538,10 @@ CAMO_KEY = get_secret("camo_key") if CAMO_URI != "" else None
# STATIC CONTENT AND MINIFICATION SETTINGS
########################################################################
if PRODUCTION or IS_DEV_DROPLET or os.getenv("EXTERNAL_HOST") is not None:
if STATIC_URL is None:
if PRODUCTION or IS_DEV_DROPLET or os.getenv("EXTERNAL_HOST") is not None:
STATIC_URL = urljoin(ROOT_DOMAIN_URI, "/static/")
else:
else:
STATIC_URL = "http://localhost:9991/static/"
LOCAL_AVATARS_DIR = os.path.join(LOCAL_UPLOADS_DIR, "avatars") if LOCAL_UPLOADS_DIR else None

View File

@ -19,6 +19,8 @@ DEBUG = DEVELOPMENT
EXTERNAL_HOST_WITHOUT_PORT = deport(EXTERNAL_HOST)
STATIC_URL: Optional[str] = None
# These settings are intended for the server admin to set. We document them in
# prod_settings_template.py, and in the initial /etc/zulip/settings.py on a new
# install of the Zulip server.

View File

@ -116,6 +116,7 @@ else:
response["Access-Control-Allow-Origin"] = "*"
return response
assert settings.STATIC_URL is not None
urls += static(urlsplit(settings.STATIC_URL).path, view=serve_static)
i18n_urls = [