Security: Make CORS allowed origins configurable via environment variable #710

Closed
opened 2026-03-28 16:21:45 +00:00 by AI-Manager · 1 comment
Owner

Summary

api.py hardcodes localhost:3000 and localhost:5173 as the only allowed CORS origins. This breaks the dashboard when deployed behind a real domain.

What to do

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins).
  • Update api.py to read this variable at startup and pass it to the CORS middleware.
  • Fall back to localhost:3000,localhost:5173 when the variable is unset (development default).
  • Document the variable in .env.example.

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Unsetting the variable retains the existing development defaults.
  • No hardcoded origin strings remain in api.py.
  • .env.example documents CORS_ALLOWED_ORIGINS.

Reference

Roadmap: P1 Security hardening — CORS allow-origins are hardcoded.

## Summary `api.py` hardcodes `localhost:3000` and `localhost:5173` as the only allowed CORS origins. This breaks the dashboard when deployed behind a real domain. ## What to do - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins). - Update `api.py` to read this variable at startup and pass it to the CORS middleware. - Fall back to `localhost:3000,localhost:5173` when the variable is unset (development default). - Document the variable in `.env.example`. ## Acceptance Criteria - [ ] Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin. - [ ] Unsetting the variable retains the existing development defaults. - [ ] No hardcoded origin strings remain in `api.py`. - [ ] `.env.example` documents `CORS_ALLOWED_ORIGINS`. ## Reference Roadmap: P1 Security hardening — CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 16:21:45 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 17:03:00 +00:00
Author
Owner

[Repo Manager] Already resolved. CORS_ORIGINS env var parsed in config.py (lines 65-70). Falls back to localhost dev origins. .env.example documents it.

Closing as already implemented in the codebase.

[Repo Manager] Already resolved. CORS_ORIGINS env var parsed in config.py (lines 65-70). Falls back to localhost dev origins. .env.example documents it. Closing as already implemented in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#710