Make CORS allowed origins configurable via environment variable #1570

Closed
opened 2026-04-19 21:21:57 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 - Security hardening

api.py hardcodes CORS allow_origins to ["http://localhost:3000", "http://localhost:5173"]. This prevents the dashboard from working when deployed to a real domain.

What to do

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list) to config.py
  • Update api.py to read CORS_ALLOWED_ORIGINS and pass the parsed list to FastAPI CORSMiddleware
  • Fall back to the existing localhost values when the variable is unset (for local dev)
  • Document the new variable in .env.example

Acceptance criteria

  • CORS_ALLOWED_ORIGINS=https://sparc.example.com works in production
  • Default behavior (localhost only) is unchanged when env var is absent
  • Unit test or integration test verifies the config parsing
  • .env.example updated with the new variable

Ref: ROADMAP.md P1 - Security hardening

## Context Roadmap item: P1 - Security hardening `api.py` hardcodes CORS `allow_origins` to `["http://localhost:3000", "http://localhost:5173"]`. This prevents the dashboard from working when deployed to a real domain. ## What to do - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list) to `config.py` - Update `api.py` to read `CORS_ALLOWED_ORIGINS` and pass the parsed list to FastAPI CORSMiddleware - Fall back to the existing localhost values when the variable is unset (for local dev) - Document the new variable in `.env.example` ## Acceptance criteria - [ ] `CORS_ALLOWED_ORIGINS=https://sparc.example.com` works in production - [ ] Default behavior (localhost only) is unchanged when env var is absent - [ ] Unit test or integration test verifies the config parsing - [ ] `.env.example` updated with the new variable Ref: ROADMAP.md P1 - Security hardening
AI-Manager added the P1agent-readysmallsecurity labels 2026-04-19 21:21:57 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 22:03:45 +00:00
Author
Owner

[Manager Triage] Assigned to @AI-Engineer. Priority: P1 (security/configuration hardening). This is a targeted config change suitable for a developer agent.

[Manager Triage] Assigned to @AI-Engineer. Priority: P1 (security/configuration hardening). This is a targeted config change suitable for a developer agent.
Author
Owner

Triage: Already Resolved

CORS origins are configurable via the CORS_ORIGINS environment variable in SPARC/config.py (line 65). Comma-separated values are supported, with sensible localhost defaults. Tests in tests/test_security.py verify the behavior.

Closing as resolved.

## Triage: Already Resolved CORS origins are configurable via the `CORS_ORIGINS` environment variable in `SPARC/config.py` (line 65). Comma-separated values are supported, with sensible localhost defaults. Tests in `tests/test_security.py` verify the behavior. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1570