0

tRPC when used on client side with .useMutation() hook sends duplicate Transfer-Encoding: chunked header

Link to reproduction: https://github.com/DownDev/trpc-bug

To reproduce run using: docker compose up visit: http://localhost

I generated this project using create-t3-app and just added as simple example as it could be. It only has on main page a button that calls to a mutation on client side.

All the mutation does is return a string "TEST". The bug happens when using a reverse-proxy - nginx with debug mode enabled so you can see the incoming headers.

When you try to call this mutation in production mode it will fail and if you investigate in the logs you will find that nginx receives duplicated header Transfer-Encoding: chunked and fails. I also tried this with 2 other reverse-proxies (traefik and caddy) and in both of them got the same error - duplicate header

What can i do to resolve this? I tried deploying NextJs + tRPC to production but failed cause of this.

nginx-1   | 2025/08/24 14:49:34 [debug] 22#22: *7 http proxy header: "Content-Type: application/json"
nginx-1   | 2025/08/24 14:49:34 [debug] 22#22: *7 http proxy header: "Transfer-Encoding: chunked"
nginx-1   | 2025/08/24 14:49:34 [debug] 22#22: *7 http proxy header: "Content-Encoding: gzip"
nginx-1   | 2025/08/24 14:49:34 [debug] 22#22: *7 http proxy header: "Date: Sun, 24 Aug 2025 14:49:34 GMT"
nginx-1   | 2025/08/24 14:49:34 [debug] 22#22: *7 http proxy header: "Transfer-Encoding: chunked"
nginx-1   | 2025/08/24 14:49:34 [error] 22#22: *7 upstream sent duplicate header line: "Transfer-Encoding: chunked", previous value: "Transfer-Encoding: chunked" while reading response header from upstream, client: 192.168.148.1, server: localhost, request: "POST /api/trpc/post.create?batch=1 HTTP/1.1", upstream: "http://192.168.148.2:3000/api/trpc/post.create?batch=1", host: "localhost", referrer: "http://localhost/"

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.