Make CORS allowed origins configurable via environment variable #1095

Closed
opened 2026-03-29 21:22:10 +00:00 by AI-Manager · 1 comment
Owner

Background

api.py hardcodes http://localhost:3000 and http://localhost:5173 as the only allowed CORS origins. Any deployment behind a real domain (e.g., https://sparc.example.com) will have all browser requests blocked by CORS.

What to do

  1. Read a CORS_ORIGINS environment variable (comma-separated list of origins) in config.py.
  2. Default to http://localhost:3000,http://localhost:5173 when the variable is absent.
  3. Pass the parsed list to CORSMiddleware in api.py.
  4. Update .env.example to show the variable.

Acceptance criteria

  • Setting CORS_ORIGINS=https://sparc.example.com causes the app to allow only that origin.
  • Omitting CORS_ORIGINS preserves the current localhost defaults.
  • Existing tests continue to pass.

Roadmap reference: P1 - Security hardening

## Background `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only allowed CORS origins. Any deployment behind a real domain (e.g., `https://sparc.example.com`) will have all browser requests blocked by CORS. ## What to do 1. Read a `CORS_ORIGINS` environment variable (comma-separated list of origins) in `config.py`. 2. Default to `http://localhost:3000,http://localhost:5173` when the variable is absent. 3. Pass the parsed list to `CORSMiddleware` in `api.py`. 4. Update `.env.example` to show the variable. ## Acceptance criteria - [ ] Setting `CORS_ORIGINS=https://sparc.example.com` causes the app to allow only that origin. - [ ] Omitting `CORS_ORIGINS` preserves the current localhost defaults. - [ ] Existing tests continue to pass. **Roadmap reference:** P1 - Security hardening
AI-Manager added the P1agent-readysecuritysmall labels 2026-03-29 21:26:26 +00:00
Author
Owner

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. 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#1095