Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DEBUG=True
SECRET_KEY=supersecretkey
DJANGO_SECRET_KEY=supersecretkey
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000

# =============================================
# БАЗА ДАННЫХ (PostgreSQL)
Expand Down
32 changes: 25 additions & 7 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,31 @@
# ====================
# CORS SETTINGS
# ====================
CORS_ALLOWED_ORIGINS = [
"http://localhost:5173", # Vite dev server
"http://127.0.0.1:5173",
"http://localhost:3000", # Alternative frontend port
"http://127.0.0.1:3000",
]
# Настройки CORS (Cross-Origin Resource Sharing)
CORS_ALLOWED_ORIGINS = env.list("CORS_ALLOWED_ORIGINS")

# Разрешить куки и заголовки авторизации
CORS_ALLOW_CREDENTIALS = True

CORS_ALLOW_ALL_ORIGINS = DEBUG # Only allow all origins in development
# Разрешенные методы (опционально, можно не указывать, так как по умолчанию разрешены безопасные методы)
CORS_ALLOW_METHODS = [
"DELETE",
"GET",
"OPTIONS",
"PATCH",
"POST",
"PUT",
]

# Разрешенные заголовки (опционально)
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
]