Merge pull request 'fix: [HOTFIX] 确保生产CORS始终包含saas.xiaoxiajianji.com' (#93) from fix/cors-production-domains into main
Tests / test (push) Failing after 1m3s
Tests / lint (push) Failing after 35s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled

This commit was merged in pull request #93.
This commit is contained in:
2026-06-28 21:56:50 +08:00
+5 -4
View File
@@ -38,10 +38,11 @@ if settings.DEBUG:
allow_origins = settings.CORS_ORIGINS # Allow localhost in debug mode
else:
# In production, filter out any wildcard "*" origins
allow_origins = [origin for origin in settings.CORS_ORIGINS if origin != "*"]
if not allow_origins:
# Default to production domains if no valid origins configured
allow_origins = ["https://xiaoxiajianji.com", "https://saas.xiaoxiajianji.com"]
allow_origins = list({origin for origin in settings.CORS_ORIGINS if origin != "*"})
# Always ensure production domains are included
for domain in ("https://xiaoxiajianji.com", "https://saas.xiaoxiajianji.com"):
if domain not in allow_origins:
allow_origins.append(domain)
app.add_middleware(
CORSMiddleware,