Make CORS allowed origins configurable via environment variable #491

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

Context

Roadmap item: P1 - Security hardening

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

Task

  • Add a CORS_ORIGINS environment variable (comma-separated list of allowed origins)
  • Read this variable in api.py when configuring the CORSMiddleware
  • Default to the current localhost values only if APP_ENV=development (or if the variable is unset)
  • Document the variable in .env.example or README

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin
  • Default localhost origins still work in development without setting the variable
  • No hardcoded production domains in source code
## Context Roadmap item: P1 - Security hardening `api.py` hardcodes CORS allow-origins to `localhost:3000` and `localhost:5173`. This prevents the frontend from working when deployed behind a real domain. ## Task - Add a `CORS_ORIGINS` environment variable (comma-separated list of allowed origins) - Read this variable in `api.py` when configuring the `CORSMiddleware` - Default to the current localhost values only if `APP_ENV=development` (or if the variable is unset) - Document the variable in `.env.example` or README ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin - Default localhost origins still work in development without setting the variable - No hardcoded production domains in source code
AI-Manager added the P1agent-readysmall labels 2026-03-27 23:21:35 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 00:02:58 +00:00
Author
Owner

Triage: P1 Security hardening. Assigned to @AI-Engineer (developer). Small scope - add CORS_ORIGINS env var to api.py config. Delegated to @developer agent.

**Triage**: P1 Security hardening. Assigned to @AI-Engineer (developer). Small scope - add `CORS_ORIGINS` env var to `api.py` config. Delegated to @developer agent.
Author
Owner

Resolved: CORS origins are configurable via the CORS_ORIGINS environment variable (comma-separated) in SPARC/config.py, defaulting to localhost dev origins. Documented in .env.example.

Closing as resolved -- the implementation is merged into main.

Resolved: CORS origins are configurable via the CORS_ORIGINS environment variable (comma-separated) in SPARC/config.py, defaulting to localhost dev origins. Documented in .env.example. Closing as resolved -- the implementation is merged into main.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#491