TRPCClientError: fetch failed
I get the below error when createTRPCProxyClient runs on BE of a Next.JS app hosted on Vercel:
I've been struggling for a while, and have no clue what's going on. Anybody experienced something similar? It seems to be coming from undici polyfilling fetch for node, but that's as far as I can go before the guessing game begins.
This is not happening locally
1 Reply
This thread is one of the top results when googling for
UND_ERR_REQ_CONTENT_LENGTH_MISMATCH
, so thought I'd add my fix to this as I recently encountered it myself.
Using Next.js app router.
First, install fetch-ponyfill.
Then update your httpBatchStreamLink by adding fetch: fetchPonyfill().fetch
.
This solved the issue for me. Hopefully this is resolved in the future and will no longer be necessary to ponyfill.