From 2bd49184a9c6b368faca07485d9a137126555214 Mon Sep 17 00:00:00 2001 From: thecyberlearn Date: Fri, 5 Sep 2025 10:25:50 +0530 Subject: [PATCH] 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 --- dokploy.json | 4 ++-- netcop_hub/production_settings.py | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/dokploy.json b/dokploy.json index 043aa6b..7e0b6e2 100644 --- a/dokploy.json +++ b/dokploy.json @@ -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" } } diff --git a/netcop_hub/production_settings.py b/netcop_hub/production_settings.py index d312b13..604ac1f 100644 --- a/netcop_hub/production_settings.py +++ b/netcop_hub/production_settings.py @@ -15,17 +15,22 @@ if allowed_hosts_str: else: ALLOWED_HOSTS = [] -# Database -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'), +# 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.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } } -} # Static files STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')