ayklee
TRPC giving 502 errors with jsonl header
I'm encountering a 502 Bad Gateway error when making a GET request to my tRPC endpoint in a production environment. This only happens when using the trpc-accept: application/jsonl header.
Environment
Runtime: bun
Deployment Stack: docker → nginx → cloudflare
tRPC version:
Request Example
Here is the frontend request triggering the issue:
Behavior
✅ Local Docker: Request works as expected.
❌ Production (Docker + Nginx + Cloudflare): Returns a 502 Bad Gateway.
When I remove the trpc-accept header or change it to "application/json", the request works fine in production.
Additional Notes
In the browser dev tools, when this request fails locally (still using Docker), the Network > Response panel shows:
This seems to be an issue with how application/jsonl is handled, either by nginx, cloudflare, or the bun server itself.
What I’ve Tried
Changing trpc-accept to application/json → Works
Removing trpc-accept altogether → Works
Reproduced only in production (cloudflare + nginx)
4 replies