chore: add proxy env settings
All checks were successful
Build and Push Docker Image / build (push) Successful in 29s
All checks were successful
Build and Push Docker Image / build (push) Successful in 29s
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
SECRET_KEY=replace-me
|
||||
DEBUG=false
|
||||
ALLOWED_HOSTS=example.com,www.example.com
|
||||
CSRF_TRUSTED_ORIGINS=https://example.com,https://www.example.com
|
||||
USE_X_FORWARDED_HOST=true
|
||||
SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,https
|
||||
SITE_NAME=SantehRay
|
||||
LOGIN_URL=/users/login/
|
||||
LOGIN_REDIRECT_URL=/users/profile/
|
||||
|
||||
@@ -45,6 +45,17 @@ def env_list(name: str, default: list[str]) -> list[str]:
|
||||
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:
|
||||
return default
|
||||
|
||||
parts = [item.strip() for item in value.split(",", 1)]
|
||||
if len(parts) != 2 or not parts[0] or not parts[1]:
|
||||
return default
|
||||
return parts[0], parts[1]
|
||||
|
||||
|
||||
ENV_FILE = Path(os.getenv("DJANGO_ENV_FILE", BASE_DIR / ".env"))
|
||||
load_env_file(ENV_FILE)
|
||||
if not ENV_FILE.exists():
|
||||
@@ -60,6 +71,15 @@ SECRET_KEY = os.getenv("SECRET_KEY", "django-insecure-*%u*i415=%@ny05mbd-j3802bc
|
||||
DEBUG = env_bool("DEBUG", True)
|
||||
|
||||
ALLOWED_HOSTS = env_list("ALLOWED_HOSTS", ["127.0.0.1", "preview-1.azimkin.dev"])
|
||||
CSRF_TRUSTED_ORIGINS = env_list(
|
||||
"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(
|
||||
"SECURE_PROXY_SSL_HEADER",
|
||||
("HTTP_X_FORWARDED_PROTO", "https"),
|
||||
)
|
||||
|
||||
# Application definition
|
||||
|
||||
|
||||
Reference in New Issue
Block a user