TRPCError: Missing content-type header
Hi, i haven't been using trpc in a while, i'm trying o setup TRPC on a fastify backend and react frontend.
I followed the example from the doc but when react tries to fetchs some data i get the following error:
Checking at the borwser network i see it is requesting the url: http://localhost:3000/trpc/test?batch=1&input=%7B%7D and i if i go to that URL i get back the data correctly.
Any idea of what could be the problem?
Solution:Jump to solution
Right after asking the question I found the problem. It something that has to do with CORS. I solved it using vite proxy to forward the request to the server and now everything works as expected
3 Replies
Are you definitely using the same version of both client and server?
V10 client may not work
Also ensure fastify isn’t set up to filter out any headers somehow, like middleware’s ahead of tRPC in the chain (I know with express there are some middlewares that cause problems for instance)
Thanks for the fast response. I'm using the same version on both client and server.
Solution
Right after asking the question I found the problem. It something that has to do with CORS. I solved it using vite proxy to forward the request to the server and now everything works as expected