Security: make CORS allowed origins configurable via environment variable #378

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

Problem

api.py hardcodes localhost:3000 and localhost:5173 as allowed origins. The dashboard breaks when deployed behind any real domain because CORS requests are rejected.

Work

  • Read allowed origins from a CORS_ALLOWED_ORIGINS environment variable (comma-separated list).
  • Fall back to localhost:3000,localhost:5173 when the variable is unset (for local dev).
  • Update config.py to expose this setting alongside other configuration.
  • Update .env.example with a CORS_ALLOWED_ORIGINS entry and documentation comment.

Acceptance Criteria

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

Reference

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

## Problem `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed origins. The dashboard breaks when deployed behind any real domain because CORS requests are rejected. ## Work - Read allowed origins from a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list). - Fall back to `localhost:3000,localhost:5173` when the variable is unset (for local dev). - Update `config.py` to expose this setting alongside other configuration. - Update `.env.example` with a `CORS_ALLOWED_ORIGINS` entry and documentation comment. ## Acceptance Criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin. - Unset variable preserves current localhost dev 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-27 17:21:30 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 18:02:25 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer. Priority: P1 Security. Delegating to @security-reviewer agent.

Scope: Read CORS origins from CORS_ALLOWED_ORIGINS env var (comma-separated), fall back to localhost defaults. Update config.py and .env.example.

**Triage:** Assigned to @AI-Engineer. Priority: P1 Security. Delegating to @security-reviewer agent. Scope: Read CORS origins from CORS_ALLOWED_ORIGINS env var (comma-separated), fall back to localhost defaults. Update config.py and .env.example.
Author
Owner

Closing as already implemented. Verified in the current codebase that all acceptance criteria are met. This was likely completed in a prior sprint but the issue was not closed.

**Closing as already implemented.** Verified in the current codebase that all acceptance criteria are met. This was likely completed in a prior sprint but the issue was not closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#378