mirror of
https://github.com/Lyxminxx/jast.git
synced 2026-10-11 12:51:51 +02:00
added cors
This commit is contained in:
1 parent
befd450016
commit
d49109ecb5
3 files changed
+29
No files matched your search
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user