Skip to content

fix(api-server): add CORS headers to streaming SSE responses#3381

Closed
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/api-server-cors-streaming
Closed

fix(api-server): add CORS headers to streaming SSE responses#3381
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/api-server-cors-streaming

Conversation

@ygd58

@ygd58 ygd58 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #3378

Problem

CORS headers were only added to non-streaming responses via aiohttp's cors_middleware. StreamResponse objects are prepared before the middleware can add headers, so streaming SSE responses were missing CORS headers.

Fix

Explicitly include _CORS_HEADERS in the StreamResponse headers dict at creation time. One-line fix.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #3573 — improved over the original approach by using _cors_headers_for_origin() to resolve the full dynamic CORS header set (including Access-Control-Allow-Origin) rather than just the static _CORS_HEADERS. Authorship preserved. Thanks @ygd58!

@teknium1 teknium1 closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: headers missing on streaming responses (stream:true)

2 participants