If your chat app’s streaming breaks in prod behind Cloudflare, set Cache-Control: no-transform.
Apparently, Cloudflare is trying to process (and compress) the response if you don’t.
import { middleware } from "../trpc";
export const withStreamingHeaders = middleware(async ({ ctx, next }) => {
// Prevent intermediaries from altering/buffering streaming responses
ctx.honoContext.header("Cache-Control", "no-transform");
// If running behind Nginx, this disables proxy buffering per response
ctx.honoContext.header("X-Accel-Buffering", "no");
return next();
});
Validate the issue
Copy your request as curl and add -H "Accept-Encoding: identity". If it works, you’ve got the same problem.
Caveat: for some reason, Chrome no longer includes cookies when copying as curl, but Firefox still does.


This post started as a thread on X.
Comments
Comments are kept in GitHub Discussions. You need a GitHub account to write one.