From 166a44bfc7156d3f41ee72ee404139693afede41 Mon Sep 17 00:00:00 2001 From: i701 Date: Thu, 13 Feb 2025 23:34:30 +0500 Subject: [PATCH] Update Django settings for allowed hosts configuration - Add dynamic ALLOWED_HOSTS configuration using environment variables - Simplify host configuration by splitting allowed hosts string - Remove redundant ALLOWED_HOSTS setting in production block --- apibase/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apibase/settings.py b/apibase/settings.py index acee129..635959d 100644 --- a/apibase/settings.py +++ b/apibase/settings.py @@ -32,6 +32,7 @@ SECRET_KEY = config("SECRET_KEY") DEBUG = config("DEBUG", cast=bool) +ALLOWED_HOSTS = str(config("ALLOWED_HOSTS", cast=str)).split(" ") if DEBUG: INTERNAL_IPS = [ "127.0.0.1", @@ -316,6 +317,7 @@ logging.config.dictConfig( } ) + if not DEBUG: SECURE_SSL_REDIRECT = config("DJANGO_SECURE_SSL_REDIRECT", cast=bool) SESSION_COOKIE_SECURE = True @@ -326,7 +328,7 @@ if not DEBUG: CSRF_TRUSTED_ORIGINS = [config("CSRF_TRUSTED_ORIGINS")] CSRF_COOKIE_DOMAIN = config("CSRF_COOKIE_DOMAIN") SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") - ALLOWED_HOSTS = str(config("ALLOWED_HOSTS", cast=str)).split(" ") + EMAIL_BACKEND = ( "django.core.mail.backends.smtp.EmailBackend" # Replace with your preferred backend