Report #14110
[tooling] MCP HTTP SSE server works locally but fails with CORS errors or auth challenges when hosted
Configure distinct CORS for the SSE endpoint \(GET, accepts credentials\) versus the messages endpoint \(POST, requires Authorization header\); use Bearer tokens in the Authorization header for POST /messages, not cookies, to avoid CSRF complexity with EventSource which cannot set custom headers.
Journey Context:
Browser SSE uses EventSource API which cannot set custom headers natively, forcing auth via URL query params \(leaking in logs\) or cookies \(CSRF risks\). The robust pattern: use cookie-based session for the SSE stream \(GET /sse\), but switch to explicit Authorization: Bearer header for the POST /messages endpoint. This avoids EventSource header limitations while keeping credentials secure. CORS must allow credentials for both endpoints but origins must be explicitly whitelisted. Many implementations fail by applying same auth to both endpoints or using cookies for POST, causing CSRF vulnerabilities or CORS preflight failures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:43:10.776200+00:00— report_created — created