Spaces:
Runtime error
Runtime error
prashantdubeypng commited on
Commit ·
7cbb2bf
1
Parent(s): 4002876
Fix: database pool max clients limits and CSRF
Browse files
videocaller/videocaller/settings.py
CHANGED
|
@@ -46,10 +46,14 @@ hf_space_host = os.environ.get('SPACE_HOST')
|
|
| 46 |
if hf_space_host and hf_space_host not in ALLOWED_HOSTS:
|
| 47 |
ALLOWED_HOSTS.append(hf_space_host)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# Trust Render.com proxy headers
|
| 50 |
if not DEBUG:
|
| 51 |
-
CSRF_TRUSTED_ORIGINS = [f'https://{host}' for host in ALLOWED_HOSTS if host not in ['localhost', '127.0.0.1']]
|
| 52 |
-
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
| 53 |
SECURE_SSL_REDIRECT = True
|
| 54 |
SESSION_COOKIE_SECURE = True
|
| 55 |
CSRF_COOKIE_SECURE = True
|
|
@@ -116,7 +120,7 @@ if database_url:
|
|
| 116 |
DATABASES = {
|
| 117 |
'default': dj_database_url.config(
|
| 118 |
default=database_url,
|
| 119 |
-
conn_max_age=
|
| 120 |
conn_health_checks=True,
|
| 121 |
)
|
| 122 |
}
|
|
|
|
| 46 |
if hf_space_host and hf_space_host not in ALLOWED_HOSTS:
|
| 47 |
ALLOWED_HOSTS.append(hf_space_host)
|
| 48 |
|
| 49 |
+
# Always trust the known external hosts for CSRF, even if DEBUG is True
|
| 50 |
+
CSRF_TRUSTED_ORIGINS = [f'https://{host}' for host in ALLOWED_HOSTS if host not in ['localhost', '127.0.0.1']]
|
| 51 |
+
|
| 52 |
+
# Important for reverse proxies (like HuggingFace Spaces and Render)
|
| 53 |
+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
| 54 |
+
|
| 55 |
# Trust Render.com proxy headers
|
| 56 |
if not DEBUG:
|
|
|
|
|
|
|
| 57 |
SECURE_SSL_REDIRECT = True
|
| 58 |
SESSION_COOKIE_SECURE = True
|
| 59 |
CSRF_COOKIE_SECURE = True
|
|
|
|
| 120 |
DATABASES = {
|
| 121 |
'default': dj_database_url.config(
|
| 122 |
default=database_url,
|
| 123 |
+
conn_max_age=0, # Disabled for serverless pooler compatibility (Supabase)
|
| 124 |
conn_health_checks=True,
|
| 125 |
)
|
| 126 |
}
|