Skip to content

Commit ea03d0f

Browse files
committed
fix(api): add SSE headers to prevent buffering & enable real-time streaming
SSE events in the Next.js 15 client were arriving in bursts (UI updated all at once) while Vite streamed fine. Root cause: intermediaries (Next proxy/CDN/Nginx) were buffering or transforming the response. Add explicit streaming-friendly headers on the SSE endpoint: - Cache-Control: no-cache, no-transform → disable caching and proxy transformations (e.g., gzip) that break chunked delivery. - Connection: keep-alive → keep the HTTP connection open for long-lived SSE. - X-Accel-Buffering: no → disable Nginx proxy buffering so chunks flush immediately.
1 parent bbf566b commit ea03d0f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/api/src/flux0_api/sessions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ async def create_event_and_stream(
631631
recording_store,
632632
),
633633
media_type="text/event-stream",
634+
headers={
635+
"Cache-Control": "no-cache, no-transform",
636+
"Connection": "keep-alive",
637+
"X-Accel-Buffering": "no",
638+
},
634639
)
635640
# elif params.source == EventSourceDTO.AI_AGENT:
636641
# return await _add_agent_message(session_id, params)

0 commit comments

Comments
 (0)