Fix admin login 500 when clients omit the trailing slash.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -149,12 +149,32 @@ MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
# Nginx / Arvan terminate TLS. Without this, Django builds http:// URLs and
|
||||
# APPEND_SLASH / CSRF see the request as HTTP.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
USE_X_FORWARDED_HOST = True
|
||||
|
||||
csrf_origins_env = os.environ.get('CSRF_TRUSTED_ORIGINS', '')
|
||||
CSRF_TRUSTED_ORIGINS = [o.strip() for o in csrf_origins_env.split(',') if o.strip()]
|
||||
if not CSRF_TRUSTED_ORIGINS:
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'https://zoneco.org',
|
||||
'https://www.zoneco.org',
|
||||
'https://panel.zoneco.org',
|
||||
]
|
||||
if DEBUG:
|
||||
CSRF_TRUSTED_ORIGINS += [
|
||||
'http://localhost:5173',
|
||||
'http://localhost:3000',
|
||||
'http://127.0.0.1:5173',
|
||||
'http://127.0.0.1:3000',
|
||||
]
|
||||
|
||||
# REST Framework configuration
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'rest_framework.authentication.BasicAuthentication',
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES': [
|
||||
'rest_framework.permissions.AllowAny',
|
||||
|
||||
Reference in New Issue
Block a user