Skip to content

fix(gateway): support localhost dev ports in CORS#1007

Open
stablegenius49 wants to merge 1 commit intobytedance:mainfrom
stablegenius49:pr-factory/issue-47-cors-localhost-ports
Open

fix(gateway): support localhost dev ports in CORS#1007
stablegenius49 wants to merge 1 commit intobytedance:mainfrom
stablegenius49:pr-factory/issue-47-cors-localhost-ports

Conversation

@stablegenius49
Copy link
Contributor

@stablegenius49 stablegenius49 commented Mar 7, 2026

Summary

  • enable FastAPI CORSMiddleware in the gateway for direct backend access in local dev
  • add a localhost/127.0.0.1 regex fallback so non-3000 frontend ports (e.g. 3001/5173) are accepted
  • trim and normalize CORS_ORIGINS parsing and add regression tests for config + middleware wiring

Verification

  • cd backend && python3 -m py_compile src/gateway/config.py src/gateway/app.py tests/test_gateway_cors.py
  • cd backend && pytest -q tests/test_gateway_cors.py (fails in this environment: ModuleNotFoundError: fastapi; backend deps are not installed here)

Closes #47

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@WillemJiang
Copy link
Collaborator

@stablegenius49 Thanks for your contribution. Please click the CLA button to sign the CLA first, and then we can review your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CORS error -- IF FrontEnd port isn't 3000

4 participants