From d8f2987cd38dfa28527f88844bb2b6812765086b Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 14:54:55 +0530 Subject: [PATCH 1/9] allowed hosts --- aviso_core/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviso_core/settings.py b/aviso_core/settings.py index f251ba5..724c445 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -27,8 +27,8 @@ # --- LOGIC FOR ALLOWED HOSTS --- if DEBUG: # Local development - ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] - CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"] + ALLOWED_HOSTS = ['*'] + CSRF_TRUSTED_ORIGINS = ['*'] else: ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') From d3b229e48dcffd6cc2640a039017b8f5046ff851 Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 15:21:08 +0530 Subject: [PATCH 2/9] logger for debugging --- aviso_core/middlewares.py | 3 +++ aviso_core/settings.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aviso_core/middlewares.py b/aviso_core/middlewares.py index 82a1cb4..b4eb1a7 100644 --- a/aviso_core/middlewares.py +++ b/aviso_core/middlewares.py @@ -31,6 +31,9 @@ def __call__(self, request): except: pass + logger.info(f"All Headers: {dict(request.headers)}") + + ## TODO: Tenant Name Extraction From Browser tenant_name = ( request.headers.get("X-Tenant-Name") or request.GET.get("tenant_name", "aviso.com") diff --git a/aviso_core/settings.py b/aviso_core/settings.py index 724c445..f251ba5 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -27,8 +27,8 @@ # --- LOGIC FOR ALLOWED HOSTS --- if DEBUG: # Local development - ALLOWED_HOSTS = ['*'] - CSRF_TRUSTED_ORIGINS = ['*'] + ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] + CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"] else: ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') From 2444cac790a840c6b2357ff5c1633f8facfb63c5 Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 15:24:43 +0530 Subject: [PATCH 3/9] health-check bypass --- aviso_core/middlewares.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aviso_core/middlewares.py b/aviso_core/middlewares.py index b4eb1a7..d009d06 100644 --- a/aviso_core/middlewares.py +++ b/aviso_core/middlewares.py @@ -16,6 +16,9 @@ def __init__(self, get_response): self.get_response = get_response def __call__(self, request): + if request.path.rstrip("/") == "/gbm/health": + return self.get_response(request) + # =========================================================== # 1. REQUEST PHASE: Initialize Context # =========================================================== From 8f38e62591e64fd85d1e8a1a294d462adc4f920b Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 16:36:32 +0530 Subject: [PATCH 4/9] health-check --- aviso_core/settings.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/aviso_core/settings.py b/aviso_core/settings.py index f251ba5..9e8e680 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -89,6 +89,26 @@ } +if DEBUG: + DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } + } +else: + 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"), + "PORT": os.environ.get("DB_PORT", "5432"), + } + } + + # Password validation # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators From 0822c0afbe4a5e61a69d32ba8bd782236326bc9f Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 16:53:49 +0530 Subject: [PATCH 5/9] health --- gbm_apis/api/health.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gbm_apis/api/health.py b/gbm_apis/api/health.py index d5aa094..d232c0f 100644 --- a/gbm_apis/api/health.py +++ b/gbm_apis/api/health.py @@ -3,7 +3,7 @@ from django.views import View from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.db import connection +# from django.db import connection from django.conf import settings logger = logging.getLogger(f'gnana.{__name__}') @@ -26,8 +26,8 @@ def get(self, request): try: ## TODO Mongo HEalth CHeck - with connection.cursor() as cursor: - cursor.execute("SELECT 1") + # with connection.cursor() as cursor: + # cursor.execute("SELECT 1") health_status["checks"]["database"] = "ok" except Exception as db_error: logger.warning(f"Database health check failed: {str(db_error)}") From 017cd2967c8abbf6d65ea4972d1f46465891cbbf Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 17:03:44 +0530 Subject: [PATCH 6/9] debug true --- aviso_core/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aviso_core/settings.py b/aviso_core/settings.py index 9e8e680..1228174 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -27,7 +27,7 @@ # --- LOGIC FOR ALLOWED HOSTS --- if DEBUG: # Local development - ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] + ALLOWED_HOSTS = ['*'] CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"] else: ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') From 2783a1bfe9c5d51dec8ca1d7ed684c3ee64a6705 Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 17:14:06 +0530 Subject: [PATCH 7/9] health-fix --- aviso_core/settings.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/aviso_core/settings.py b/aviso_core/settings.py index 1228174..ed726b3 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -89,24 +89,24 @@ } -if DEBUG: - DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } - } -else: - 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"), - "PORT": os.environ.get("DB_PORT", "5432"), - } - } +# if DEBUG: +# DATABASES = { +# "default": { +# "ENGINE": "django.db.backends.sqlite3", +# "NAME": BASE_DIR / "db.sqlite3", +# } +# } +# else: +# 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"), +# "PORT": os.environ.get("DB_PORT", "5432"), +# } +# } # Password validation From 5aa62c31878ca82f48739c648681d5ee949d76fa Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 18:07:44 +0530 Subject: [PATCH 8/9] allowed_hosts --- aviso_core/settings.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/aviso_core/settings.py b/aviso_core/settings.py index ed726b3..d22ede9 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -25,16 +25,10 @@ DEBUG = os.environ.get('DEBUG', 'True') == 'True' # --- LOGIC FOR ALLOWED HOSTS --- -if DEBUG: - # Local development - ALLOWED_HOSTS = ['*'] - CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"] -else: - ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') - trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') - CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()] - -# Application definition + +ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') +trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') +CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()] INSTALLED_APPS = [ 'django.contrib.admin', From 1a8abcbcd4353883e35d3e5e78abfec0fe5d5473 Mon Sep 17 00:00:00 2001 From: Ujjawal Golani Date: Fri, 20 Feb 2026 20:24:51 +0530 Subject: [PATCH 9/9] remove extra logger --- aviso_core/middlewares.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/aviso_core/middlewares.py b/aviso_core/middlewares.py index d009d06..0d73a87 100644 --- a/aviso_core/middlewares.py +++ b/aviso_core/middlewares.py @@ -34,9 +34,6 @@ def __call__(self, request): except: pass - logger.info(f"All Headers: {dict(request.headers)}") - - ## TODO: Tenant Name Extraction From Browser tenant_name = ( request.headers.get("X-Tenant-Name") or request.GET.get("tenant_name", "aviso.com")