tRPC 404 in Next.js API Routes
I'm trying to upgrade my Next.js version to 15 and still use tRPC with API route. I'm getting 404 for all trpc api routes. Is anyone else facing the same issue? All the other api routes are working fine.
app/api/trpc/[trpc]/route.ts
trpc.ts
5 Replies
If you console.log at the line above awaiting the
fetchRequestHandler
, does it log anything?
Also, I have a createContext
for the fetchRequestHandler
- maybe that's needed?It doesnt log anything. If I remove the fetchRequestHandler completely and leave the console.log there, it logs.
that's my working file. Could you try to alter it to use your imports/naming but keep the exports and other function definitions?
Maybe something strange regarding the handler refs, etc. is happening? I feel like I'm missing something obvious... 😅
and remove the createContext from mine. i think that's optional
Sorry I should probably have put the full code, I needed to make is more simple since it's related to work and it's private.
I found the reason from createContext :D
we are passing google cloud task client to the context which is for some reason causing it
That's fine. Glad I could help!