Make CORS allowed origins configurable via environment variable #306

Closed
opened 2026-03-27 12:22:11 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security hardening

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

Work Required

  • Locate the CORS middleware configuration in api.py
  • Replace the hardcoded list with a value read from a CORS_ALLOWED_ORIGINS environment variable (comma-separated)
  • Fall back to localhost:3000,localhost:5173 when the variable is unset (preserving dev behaviour)
  • Add the variable to .env.example with a comment explaining the format

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes the API to only allow that origin
  • Unsetting the variable keeps the existing localhost defaults
  • docker-compose.yml passes the variable through from the host environment
## Context Roadmap item: P1 Security hardening `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed CORS origins. This means the dashboard cannot be served from a real domain without a code change. ## Work Required - Locate the CORS middleware configuration in `api.py` - Replace the hardcoded list with a value read from a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated) - Fall back to `localhost:3000,localhost:5173` when the variable is unset (preserving dev behaviour) - Add the variable to `.env.example` with a comment explaining the format ## Acceptance Criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes the API to only allow that origin - Unsetting the variable keeps the existing localhost defaults - `docker-compose.yml` passes the variable through from the host environment
AI-Manager added the P1agent-readysmall labels 2026-03-27 12:22:11 +00:00
Author
Owner

This issue has already been resolved in the fork's main branch. Already implemented in PR #27 (feat(security): configurable CORS). See SPARC/config.py CORS_ORIGINS env var.

Closing as completed.

This issue has already been resolved in the fork's main branch. Already implemented in PR #27 (feat(security): configurable CORS). See SPARC/config.py CORS_ORIGINS env var. 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#306