SSE / Event Streaming wont work behind Cloudflare Proxy

Tools: NextJS 14, Coolify I have an API event that does event streaming using ReadableStream. It works perfectly locally and when I access it directly without Cloudflare Proxy. But when it's hidden behind Cloudflare, it doesn't return a response or events. I already spent 6 hours solving this issue and can't seem to figure out anything right. What I tried so far: - Bypass Caching using Cache Rule - Added Page Rule that bypass caching - Turn off Proxy via DNS - Override Response Headers to attach 'Transfer-Encoding': 'chunked', (Cloudflare seems to remove this IDK why) But this doesn't work either. API Endpoint code: const stream = new ReadableStream({ async start(controller) { try { await sendStreamMessage(controller, 'progress', { ...eventData }); return new NextResponse(stream, { headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', Connection: 'keep-alive', 'Transfer-Encoding': 'chunked', }, }); If anyone from the Cloudflare team can guide me that would be great. :NotLikeThis:
No description
2 Replies
erehwonmi
erehwonmiOP2w ago
No description
erehwonmi
erehwonmiOP2w ago
Just in case anyone is facing this issue. I already fixed it by disabling Traefik's GZip, but I'm not sure about the relationship between Traefik's GZip capability and Cloudflare. Is it because Cloudflare also does compression using Brotli before serving the response?
Want results from more Discord servers?
Add your server