mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 22:32:57 +00:00
🔒 Fix CSRF verification failed error for Railway domain
- Add quantum-ai.up.railway.app to CSRF_TRUSTED_ORIGINS - Include development origins (localhost, 127.0.0.1) - Improve Railway domain detection with fallback - Prevent duplicate domain entries Fixes 403 CSRF verification failed errors on login and admin forms. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8538b63246
commit
d2358fb0bb
@ -296,11 +296,24 @@ EMAIL_TIMEOUT = 30
|
|||||||
# Security settings
|
# Security settings
|
||||||
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in config('CSRF_TRUSTED_ORIGINS', default='').split(',') if origin.strip()]
|
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in config('CSRF_TRUSTED_ORIGINS', default='').split(',') if origin.strip()]
|
||||||
|
|
||||||
|
# Always include common development origins
|
||||||
|
CSRF_TRUSTED_ORIGINS.extend([
|
||||||
|
'http://localhost:8000',
|
||||||
|
'http://127.0.0.1:8000',
|
||||||
|
'https://localhost:8000',
|
||||||
|
'https://127.0.0.1:8000'
|
||||||
|
])
|
||||||
|
|
||||||
# Add Railway domain if running on Railway
|
# Add Railway domain if running on Railway
|
||||||
if config('RAILWAY_ENVIRONMENT', default=''):
|
if config('RAILWAY_ENVIRONMENT', default=''):
|
||||||
|
# Add known Railway domain
|
||||||
|
CSRF_TRUSTED_ORIGINS.append('https://quantum-ai.up.railway.app')
|
||||||
|
|
||||||
|
# Try to get Railway public domain from environment
|
||||||
railway_url = config('RAILWAY_PUBLIC_DOMAIN', default='')
|
railway_url = config('RAILWAY_PUBLIC_DOMAIN', default='')
|
||||||
if railway_url:
|
if railway_url and f'https://{railway_url}' not in CSRF_TRUSTED_ORIGINS:
|
||||||
CSRF_TRUSTED_ORIGINS.append(f'https://{railway_url}')
|
CSRF_TRUSTED_ORIGINS.append(f'https://{railway_url}')
|
||||||
|
|
||||||
# Also add production domain
|
# Also add production domain
|
||||||
CSRF_TRUSTED_ORIGINS.append('https://quantumtaskai.com')
|
CSRF_TRUSTED_ORIGINS.append('https://quantumtaskai.com')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user