fix: normalize coolify host env
All checks were successful
Build and Push Docker Image / build (push) Successful in 26s
All checks were successful
Build and Push Docker Image / build (push) Successful in 26s
This commit is contained in:
@@ -39,13 +39,6 @@ def env_bool(name: str, default: bool = False) -> bool:
|
||||
return os.getenv(name, str(default)).lower() in {"1", "true", "yes", "on"}
|
||||
|
||||
|
||||
def env_list(name: str, default: list[str]) -> list[str]:
|
||||
value = os.getenv(name)
|
||||
if value is None or not value.strip():
|
||||
return default
|
||||
return [item.strip() for item in value.split(",") if item.strip()]
|
||||
|
||||
|
||||
def env_pair(name: str, default: tuple[str, str]) -> tuple[str, str]:
|
||||
value = os.getenv(name)
|
||||
if not value:
|
||||
@@ -159,16 +152,12 @@ SECRET_KEY = os.getenv("SECRET_KEY", "django-insecure-*%u*i415=%@ny05mbd-j3802bc
|
||||
DEBUG = env_bool("DEBUG", True)
|
||||
|
||||
ALLOWED_HOSTS = merge_unique(
|
||||
collect_hosts("COOLIFY_FQDN", "COOLIFY_URL"),
|
||||
env_list("ALLOWED_HOSTS", ["127.0.0.1", "localhost", "preview-1.azimkin.dev"]),
|
||||
)
|
||||
CSRF_TRUSTED_ORIGINS = env_list(
|
||||
"CSRF_TRUSTED_ORIGINS",
|
||||
["https://preview-1.azimkin.dev", "http://127.0.0.1", "http://localhost"],
|
||||
collect_hosts("COOLIFY_FQDN", "COOLIFY_URL", "ALLOWED_HOSTS"),
|
||||
["127.0.0.1", "localhost", "preview-1.azimkin.dev"],
|
||||
)
|
||||
CSRF_TRUSTED_ORIGINS = merge_unique(
|
||||
collect_origins("COOLIFY_URL", "COOLIFY_FQDN"),
|
||||
CSRF_TRUSTED_ORIGINS,
|
||||
collect_origins("COOLIFY_URL", "COOLIFY_FQDN", "CSRF_TRUSTED_ORIGINS"),
|
||||
["https://preview-1.azimkin.dev", "http://127.0.0.1", "http://localhost"],
|
||||
)
|
||||
USE_X_FORWARDED_HOST = env_bool("USE_X_FORWARDED_HOST", True)
|
||||
SECURE_PROXY_SSL_HEADER = env_pair(
|
||||
|
||||
Reference in New Issue
Block a user