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)
2 Replies
This is my Dockerfile and docker-compose, by the way
@ayklee I'm experiencing the same issue (both in standalone and in regular Next.js
output
mode, using DigitalOcean and Dokploy). Weirdly enough, deploying with nixpacks
works, but I'm trying to move away from nickpacks
. Going to try your workarounds...
UPD: httpBatchStreamLink
seems to be the culprit. Replacing it with httpBatchLink
works as well.