Closed mohitxskull closed 1 year ago
I'm running into the same error with a similar set up as you, could you share your solution if you don't mind ?
I'm hitting this same issue now, what was the resolution here?
Commenting here as I just ran into the same issue. Just finished setting up Hono with tRPC and my procedure throws a 404 for whatever reason. What I did was change the base path of tRPC:
// Does not work
app.use(
"/v1",
trpcServer({
router: trpcRouter,
createContext
})
)
// Works, yay
app.use(
"/trpc/*",
trpcServer({
router: trpcRouter,
createContext
})
)
I ran into the same issue and spent some time digging into the source code for both @hono/trpc-server
and @trpc/server
. It turns out the reason only the /trpc/*
route works is because the internal fetchRequestHandler
fn expects an endpoint
to extract the procedure path correctly. The default is /trpc
, so if your route is different, it breaks. To fix it, just pass an endpoint argument matching your middleware route
app.use(
'/back/trpc/*',
trpcServer({
endpoint: '/back/trpc',
router: appRouter,
})
);
TRPC routes are there but still getting 404
TURBOREPO
src/trpc/init.ts
src/trpc/index.ts
src/index.ts
Thank you!