fix: Update ALLOWED_HOSTS and CORS_ALLOWED_ORIGINS defaults in Django settings

This commit is contained in:
pacnpal
2025-09-19 15:39:45 -04:00
parent a5fd56b117
commit 01195e198c
2 changed files with 6 additions and 7 deletions

View File

@@ -13,12 +13,12 @@ from decouple import config
DEBUG = config("DEBUG", default=True) DEBUG = config("DEBUG", default=True)
SECRET_KEY = config("SECRET_KEY") SECRET_KEY = config("SECRET_KEY")
ALLOWED_HOSTS = config("ALLOWED_HOSTS") ALLOWED_HOSTS = config("ALLOWED_HOSTS", default="localhost,127.0.0.1", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
DATABASE_URL = config("DATABASE_URL") DATABASE_URL = config("DATABASE_URL")
CACHE_URL = config("CACHE_URL", default="locmem://") CACHE_URL = config("CACHE_URL", default="locmem://")
EMAIL_URL = config("EMAIL_URL", default="console://") EMAIL_URL = config("EMAIL_URL", default="console://")
REDIS_URL = config("REDIS_URL", default="redis://127.0.0.1:6379/1") REDIS_URL = config("REDIS_URL", default="redis://127.0.0.1:6379/1")
CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS", default=[]) CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS", default="", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
API_RATE_LIMIT_PER_MINUTE = config("API_RATE_LIMIT_PER_MINUTE", default=60) API_RATE_LIMIT_PER_MINUTE = config("API_RATE_LIMIT_PER_MINUTE", default=60)
API_RATE_LIMIT_PER_HOUR = config("API_RATE_LIMIT_PER_HOUR", default=1000) API_RATE_LIMIT_PER_HOUR = config("API_RATE_LIMIT_PER_HOUR", default=1000)
CACHE_MIDDLEWARE_SECONDS = config("CACHE_MIDDLEWARE_SECONDS", default=300) CACHE_MIDDLEWARE_SECONDS = config("CACHE_MIDDLEWARE_SECONDS", default=300)
@@ -43,13 +43,12 @@ if apps_dir.exists() and str(apps_dir) not in sys.path:
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config("SECRET_KEY") SECRET_KEY = config("SECRET_KEY")
# Allowed hosts # Allowed hosts (already configured above)
ALLOWED_HOSTS = config("ALLOWED_HOSTS")
# CSRF trusted origins # CSRF trusted origins
CSRF_TRUSTED_ORIGINS = config( CSRF_TRUSTED_ORIGINS = config(
"CSRF_TRUSTED_ORIGINS", default=[] "CSRF_TRUSTED_ORIGINS", default="", cast=lambda v: [s.strip() for s in v.split(',') if s.strip()]
) # type: ignore[arg-type] )
# Application definition # Application definition
DJANGO_APPS = [ DJANGO_APPS = [

View File

@@ -107,7 +107,7 @@ urlpatterns = [
if HAS_AUTOCOMPLETE and autocomplete_urls: if HAS_AUTOCOMPLETE and autocomplete_urls:
urlpatterns.insert( urlpatterns.insert(
2, 2,
path("ac/", include(autocomplete_urls)), path("ac/", include(autocomplete_urls[:2], namespace=autocomplete_urls[2])),
) )
# Add API Documentation URLs if available # Add API Documentation URLs if available