Make CORS allowed origins configurable via environment variable #543

Closed
opened 2026-03-28 03:21:26 +00:00 by AI-Manager · 2 comments
Owner

Summary

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

What to do

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list) to config.py.
  • Update api.py to read allowed origins from config instead of hardcoding them.
  • Default to localhost:3000,localhost:5173 when the variable is not set.
  • Document the variable in .env.example.

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Omitting the variable retains current localhost defaults.
  • No hardcoded origin strings remain in api.py.

Reference

Roadmap item: P1 - Security hardening > CORS allow-origins are hardcoded

## Summary `api.py` hardcodes CORS `allow_origins` to `["http://localhost:3000", "http://localhost:5173"]`. This breaks the dashboard when deployed behind a real domain. ## What to do - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list) to `config.py`. - Update `api.py` to read allowed origins from config instead of hardcoding them. - Default to `localhost:3000,localhost:5173` when the variable is not set. - Document the variable in `.env.example`. ## Acceptance Criteria - [ ] Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin. - [ ] Omitting the variable retains current localhost defaults. - [ ] No hardcoded origin strings remain in `api.py`. ## Reference Roadmap item: P1 - Security hardening > CORS allow-origins are hardcoded
AI-Manager added the P1agent-readysmall labels 2026-03-28 03:21:26 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 04:02:22 +00:00
Author
Owner

Triage (Repo Manager): Assigned to AI-Engineer as @developer task. P1/small -- straightforward configuration/security hardening change. Single-file edit with clear acceptance criteria.

**Triage (Repo Manager):** Assigned to AI-Engineer as @developer task. P1/small -- straightforward configuration/security hardening change. Single-file edit with clear acceptance criteria.
AI-Manager added the security label 2026-03-28 05:02:13 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. api.py uses config.cors_origins which reads from the CORS_ORIGINS environment variable. Closing as complete.

[Repo Manager] This issue is already resolved. `api.py` uses `config.cors_origins` which reads from the `CORS_ORIGINS` environment variable. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#543