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",
"DEBUG": "false",
"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",
"SECURE_SSL_REDIRECT": "false",
"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,15 +15,20 @@ if allowed_hosts_str:
else:
ALLOWED_HOSTS = []
# Database
# Database - use PostgreSQL if DATABASE_URL is provided, otherwise SQLite
DATABASE_URL = os.environ.get('DATABASE_URL')
if DATABASE_URL:
# Parse DATABASE_URL for PostgreSQL
import dj_database_url
DATABASES = {
'default': dj_database_url.parse(DATABASE_URL)
}
else:
# Use SQLite for simple deployments
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME'),
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', '5432'),
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}