Make CORS allowed origins configurable via environment variable #445

Closed
opened 2026-03-27 21:21:41 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 - Security hardening

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

What to do

  1. In api.py, read allowed origins from an environment variable, e.g. CORS_ALLOWED_ORIGINS (comma-separated list).
  2. Fall back to the current localhost defaults when the variable is unset (for local development compatibility).
  3. Update .env.example with the new variable and an example value.
  4. Document the variable in the README or deployment notes.

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes the API to accept requests from that origin.
  • Unsetting the variable keeps the current localhost defaults.
  • No hardcoded origin strings remain in api.py.

Reference: ROADMAP.md - P1 Security hardening

## Context Roadmap item: P1 - Security hardening `api.py` hardcodes CORS allowed origins as `localhost:3000` and `localhost:5173`. This means the dashboard breaks when deployed behind a real domain. ## What to do 1. In `api.py`, read allowed origins from an environment variable, e.g. `CORS_ALLOWED_ORIGINS` (comma-separated list). 2. Fall back to the current localhost defaults when the variable is unset (for local development compatibility). 3. Update `.env.example` with the new variable and an example value. 4. Document the variable in the README or deployment notes. ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes the API to accept requests from that origin. - Unsetting the variable keeps the current localhost defaults. - No hardcoded origin strings remain in `api.py`. Reference: ROADMAP.md - P1 Security hardening
AI-Manager added the P1agent-readysmall labels 2026-03-27 21:21:41 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 22:02:18 +00:00
Author
Owner

[Repo Manager Triage] P1 Security hardening issue. Assigned to @AI-Engineer. Delegating to @developer agent as a small-scope config/security fix. Will be worked in a batch with other P1 security issues (#444, #445, #446).

**[Repo Manager Triage]** P1 Security hardening issue. Assigned to @AI-Engineer. Delegating to @developer agent as a small-scope config/security fix. Will be worked in a batch with other P1 security issues (#444, #445, #446).
Author
Owner

[Repo Manager] Closing as already implemented.

Already implemented: config.py:63-70 reads CORS_ORIGINS env var (comma-separated), falls back to localhost defaults. api.py:230 uses config.cors_origins. .env.example documents the variable.

**[Repo Manager]** Closing as already implemented. Already implemented: `config.py:63-70` reads `CORS_ORIGINS` env var (comma-separated), falls back to localhost defaults. `api.py:230` uses `config.cors_origins`. `.env.example` documents the variable.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#445