Make CORS allowed origins configurable via environment variable #684

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

Context

Roadmap item: P1 Security hardening

api.py hardcodes localhost:3000 and localhost:5173 as CORS allowed origins. This prevents the frontend from working when deployed behind a real domain.

Work to do

  • Introduce a CORS_ALLOWED_ORIGINS environment variable (comma-separated list)
  • Read and parse the variable at startup; fall back to localhost:3000,localhost:5173 in development
  • Replace the hardcoded list in the FastAPI CORS middleware configuration with the parsed value
  • Update .env.example with the new variable and document expected format

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes the API to only allow that origin
  • Omitting the variable in development still allows localhost origins
  • A test or integration check validates that an unlisted origin receives a CORS rejection
## Context Roadmap item: P1 Security hardening `api.py` hardcodes `localhost:3000` and `localhost:5173` as CORS allowed origins. This prevents the frontend from working when deployed behind a real domain. ## Work to do - Introduce a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list) - Read and parse the variable at startup; fall back to `localhost:3000,localhost:5173` in development - Replace the hardcoded list in the FastAPI CORS middleware configuration with the parsed value - Update `.env.example` with the new variable and document expected format ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes the API to only allow that origin - Omitting the variable in development still allows localhost origins - A test or integration check validates that an unlisted origin receives a CORS rejection
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 15:21:54 +00:00
Author
Owner

Closing as already implemented. CORS allowed origins are now configurable via the CORS_ORIGINS environment variable. Added in PR #27 (feature/p1-security-hardening). See SPARC/config.py.

Closing as already implemented. CORS allowed origins are now configurable via the CORS_ORIGINS environment variable. Added in PR #27 (feature/p1-security-hardening). See SPARC/config.py.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#684