Make CORS allowed origins configurable via environment variable #925

Closed
opened 2026-03-29 08:21:29 +00:00 by AI-Manager · 1 comment
Owner

Summary

api.py hardcodes localhost:3000 and localhost:5173 as the only permitted CORS origins. This means the dashboard cannot be served from any real domain without a code change.

Roadmap Reference

P1 Security hardening -- CORS allow-origins are hardcoded (ROADMAP.md)

What to do

  1. In api.py, read a CORS_ALLOW_ORIGINS environment variable (comma-separated list).
  2. Fall back to http://localhost:3000,http://localhost:5173 when the variable is unset (development convenience).
  3. Pass the parsed list to CORSMiddleware.
  4. Document CORS_ALLOW_ORIGINS in .env.example and any deployment docs.

Acceptance criteria

  • Setting CORS_ALLOW_ORIGINS=https://sparc.example.com in the environment allows requests from that origin.
  • When unset, the existing localhost origins continue to work.
  • A preflight request from an unlisted origin receives a 403.
## Summary `api.py` hardcodes `localhost:3000` and `localhost:5173` as the only permitted CORS origins. This means the dashboard cannot be served from any real domain without a code change. ## Roadmap Reference P1 Security hardening -- CORS allow-origins are hardcoded (ROADMAP.md) ## What to do 1. In `api.py`, read a `CORS_ALLOW_ORIGINS` environment variable (comma-separated list). 2. Fall back to `http://localhost:3000,http://localhost:5173` when the variable is unset (development convenience). 3. Pass the parsed list to `CORSMiddleware`. 4. Document `CORS_ALLOW_ORIGINS` in `.env.example` and any deployment docs. ## Acceptance criteria - Setting `CORS_ALLOW_ORIGINS=https://sparc.example.com` in the environment allows requests from that origin. - When unset, the existing localhost origins continue to work. - A preflight request from an unlisted origin receives a 403.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 08:21:29 +00:00
Author
Owner

This issue has been resolved. SPARC/config.py lines 64-70 read CORS_ORIGINS from the environment (comma-separated) and fall back to localhost dev origins when unset. docker-compose.yml passes CORS_ORIGINS: ${CORS_ORIGINS:-}. Closing as completed.

This issue has been resolved. `SPARC/config.py` lines 64-70 read `CORS_ORIGINS` from the environment (comma-separated) and fall back to localhost dev origins when unset. `docker-compose.yml` passes `CORS_ORIGINS: ${CORS_ORIGINS:-}`. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#925