added cors

This commit is contained in:
Lyxminxx committed 2026-09-21 21:54:14 +02:00
1 parent befd450016
commit d49109ecb5
3 files changed
+29

No files matched your search

+13
View File
@@ -55,12 +55,14 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'core',
'ninja',
'corsheaders',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
"corsheaders.middleware.CorsMiddleware",
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -70,6 +72,17 @@ MIDDLEWARE = [
ROOT_URLCONF = 'core.urls'
cors_env = os.getenv("CORS_ALLOWED_ORIGINS", "")
if cors_env:
CORS_ALLOWED_ORIGINS = [origin.strip() for origin in cors_env.split(",") if origin.strip()]
else:
CORS_ALLOWED_ORIGINS = [
"https://jast.mydomain.com",
]
# Allow credentials (cookies/headers)
CORS_ALLOW_CREDENTIALS = True
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',