Skip to content

Commit 74ad7e2

Browse files
Fixed Failed Fetch Issue (#413)
1 parent d9ff2c3 commit 74ad7e2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

backend/backend/settings.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,18 @@
147147
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
148148

149149
if DEBUG:
150-
CORS_ALLOWED_ORIGINS = [
151-
env.str('VISUAL_CIRCUIT_FRONTEND_HOST')
152-
]
150+
# Accept a comma-separated list of frontend hosts (e.g. http://localhost:4000)
151+
# Also automatically append standard fallback ports if the primary port gets busy
152+
base_origins = [origin.strip() for origin in env.str('VISUAL_CIRCUIT_FRONTEND_HOST').split(',')]
153+
CORS_ALLOWED_ORIGINS = list(base_origins)
154+
155+
# If using localhost:4000, dynamically add 4001 and 4002 as fallbacks
156+
for origin in base_origins:
157+
if origin.endswith(':4000'):
158+
CORS_ALLOWED_ORIGINS.extend([
159+
origin.replace(':4000', ':4001'),
160+
origin.replace(':4000', ':4002')
161+
])
153162
# if DEBUG:
154163
# CORS_ALLOWED_ORIGINS = [
155164
# env.str('VISUAL_CIRCUIT_FRONTEND_HOST'),

0 commit comments

Comments
 (0)