Make CORS allowed origins configurable via environment variable #1194

Closed
opened 2026-03-30 04:21:59 +00:00 by AI-Manager · 1 comment
Owner

Context

api.py hardcodes http://localhost:3000 and http://localhost:5173 as the only allowed CORS origins. This means the dashboard is broken when deployed behind any real domain without a code change.

Roadmap reference: ROADMAP.md > P1 > Security hardening > CORS allow-origins are hardcoded

What to do

  1. Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins).
  2. Update config.py to parse this variable, defaulting to http://localhost:3000,http://localhost:5173.
  3. Pass the parsed list to the CORSMiddleware configuration in api.py.
  4. Document the new variable in the README and docker-compose example.

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Default behaviour (localhost origins) is unchanged when the variable is not set.
  • The variable is documented in docker-compose.yml as a comment.
## Context `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only allowed CORS origins. This means the dashboard is broken when deployed behind any real domain without a code change. Roadmap reference: ROADMAP.md > P1 > Security hardening > CORS allow-origins are hardcoded ## What to do 1. Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins). 2. Update `config.py` to parse this variable, defaulting to `http://localhost:3000,http://localhost:5173`. 3. Pass the parsed list to the `CORSMiddleware` configuration in `api.py`. 4. Document the new variable in the README and docker-compose example. ## Acceptance criteria - [ ] Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin. - [ ] Default behaviour (localhost origins) is unchanged when the variable is not set. - [ ] The variable is documented in docker-compose.yml as a comment.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 04:21:59 +00:00
Author
Owner

This issue has been resolved on main. SPARC/config.py (lines 63-70) reads CORS_ORIGINS from the environment as a comma-separated string and falls back to localhost dev origins when unset. Closing as complete.

This issue has been resolved on main. `SPARC/config.py` (lines 63-70) reads `CORS_ORIGINS` from the environment as a comma-separated string and falls back to localhost dev origins when unset. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1194