mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 06:52:54 +00:00
Add CSRF_TRUSTED_ORIGINS support for domain configuration
- Add CSRF_TRUSTED_ORIGINS setting to read from environment variable - Update docker-compose.dokploy.yml with correct domain dt.netcoptech.com - Update dokploy.json with proper domain configuration - Fix 500 error by supporting CSRF trusted origins for production domains
This commit is contained in:
parent
aa94261cb8
commit
31ab604b7c
@ -1,7 +1,7 @@
|
||||
# Django Configuration
|
||||
SECRET_KEY=your-secret-key-here-make-it-long-and-random
|
||||
DEBUG=True
|
||||
ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
|
||||
DEBUG=False
|
||||
ALLOWED_HOSTS=dt.netcoptech.com,localhost,127.0.0.1,0.0.0.0
|
||||
|
||||
# Database Configuration
|
||||
# Option 1: Individual variables (for Docker Compose/local development)
|
||||
@ -44,7 +44,8 @@ GOOGLE_OAUTH2_CLIENT_ID=your-google-client-id
|
||||
GOOGLE_OAUTH2_CLIENT_SECRET=your-google-client-secret
|
||||
|
||||
# Production SSL Settings (set to True in production)
|
||||
SECURE_SSL_REDIRECT=False
|
||||
SECURE_SSL_REDIRECT=True
|
||||
CSRF_TRUSTED_ORIGINS=https://dt.netcoptech.com
|
||||
|
||||
# Sentry (optional - for error tracking in production)
|
||||
SENTRY_DSN=your-sentry-dsn-here
|
||||
@ -13,6 +13,9 @@ DEBUG = config('DEBUG', default=False, cast=bool)
|
||||
|
||||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1', cast=lambda v: [s.strip() for s in v.split(',')])
|
||||
|
||||
# CSRF trusted origins for production
|
||||
CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default='', cast=lambda v: [s.strip() for s in v.split(',') if s.strip()])
|
||||
|
||||
DJANGO_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
|
||||
@ -25,7 +25,7 @@ services:
|
||||
- dokploy-network
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.django-app.rule=Host(`your-domain.com`)"
|
||||
- "traefik.http.routers.django-app.rule=Host(`dt.netcoptech.com`)"
|
||||
- "traefik.http.routers.django-app.entrypoints=websecure"
|
||||
- "traefik.http.routers.django-app.tls.certResolver=letsencrypt"
|
||||
- "traefik.http.services.django-app.loadbalancer.server.port=8000"
|
||||
|
||||
@ -20,9 +20,14 @@
|
||||
},
|
||||
{
|
||||
"key": "ALLOWED_HOSTS",
|
||||
"value": "your-domain.com,www.your-domain.com",
|
||||
"value": "dt.netcoptech.com,localhost,127.0.0.1",
|
||||
"description": "Comma-separated list of allowed hosts"
|
||||
},
|
||||
{
|
||||
"key": "CSRF_TRUSTED_ORIGINS",
|
||||
"value": "https://dt.netcoptech.com",
|
||||
"description": "CSRF trusted origins for production"
|
||||
},
|
||||
{
|
||||
"key": "DB_NAME",
|
||||
"value": "django_db",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user