Fix database configuration and add actual domain

- Add quamtumtaskai.netcoptech.com to ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS
- Fix database configuration to fallback to SQLite when no PostgreSQL DATABASE_URL provided
- This should resolve the 502 Bad Gateway error caused by database connection failures
This commit is contained in:
thecyberlearn 2025-09-05 10:25:50 +05:30
parent 5b4bc80b03
commit 2bd49184a9
2 changed files with 17 additions and 12 deletions

View File

@ -14,10 +14,10 @@
"PYTHONUNBUFFERED": "1", "PYTHONUNBUFFERED": "1",
"DEBUG": "false", "DEBUG": "false",
"SECRET_KEY": "production-key-change-this-123456789", "SECRET_KEY": "production-key-change-this-123456789",
"ALLOWED_HOSTS": "*", "ALLOWED_HOSTS": "quamtumtaskai.netcoptech.com,website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me,*",
"DOKPLOY_PROJECT_NAME": "quantum-tasks-ai", "DOKPLOY_PROJECT_NAME": "quantum-tasks-ai",
"SECURE_SSL_REDIRECT": "false", "SECURE_SSL_REDIRECT": "false",
"SECURE_PROXY_SSL_HEADER": "HTTP_X_FORWARDED_PROTO,https", "SECURE_PROXY_SSL_HEADER": "HTTP_X_FORWARDED_PROTO,https",
"CSRF_TRUSTED_ORIGINS": "https://website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me,http://website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me" "CSRF_TRUSTED_ORIGINS": "https://quamtumtaskai.netcoptech.com,http://quamtumtaskai.netcoptech.com,https://website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me,http://website-quantumtaskai-wrczik-cc50ac-31-97-62-205.traefik.me"
} }
} }

View File

@ -15,17 +15,22 @@ if allowed_hosts_str:
else: else:
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
# Database # Database - use PostgreSQL if DATABASE_URL is provided, otherwise SQLite
DATABASES = { DATABASE_URL = os.environ.get('DATABASE_URL')
'default': { if DATABASE_URL:
'ENGINE': 'django.db.backends.postgresql', # Parse DATABASE_URL for PostgreSQL
'NAME': os.environ.get('DB_NAME'), import dj_database_url
'USER': os.environ.get('DB_USER'), DATABASES = {
'PASSWORD': os.environ.get('DB_PASSWORD'), 'default': dj_database_url.parse(DATABASE_URL)
'HOST': os.environ.get('DB_HOST', 'localhost'), }
'PORT': os.environ.get('DB_PORT', '5432'), else:
# Use SQLite for simple deployments
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
} }
}
# Static files # Static files
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')