NilsB
NilsB7d ago

Error trying to serve TRPC from custom path in Hono

I'm successfully serving a basic "hello world" using the default root path:
proxyApp.use("/trpc/*",
trpcServer({
router: appRouter,
})
)
proxyApp.use("/trpc/*",
trpcServer({
router: appRouter,
})
)
I can see the Hello World greeting I defined when I run curl http://localhost:3000/trpc/getGreeting However, if I make a trivial change to the URL, like serving it from "/trpc2/*", trpc fails with a not-found error with a weird mangled path:
{"error":{"message":"No procedure found on path \"2/getGreeting\"","code":-32004,"data":{"code":"NOT_FOUND","httpStatus":404, ... }}}
{"error":{"message":"No procedure found on path \"2/getGreeting\"","code":-32004,"data":{"code":"NOT_FOUND","httpStatus":404, ... }}}
(notice the first four characters missing on the path in the error message) I'm using Hono and the new tanstack-query-trpc integration. Am I missing something? Why is the path mangled in the error message?
2 Replies
FluX
FluX6d ago
Not at my PC right now, but try to add an endpoint to trpcServer app.use( "/api/*", trpcServer({ endpoint: "/api", router: appRouter, createContext }) )
NilsB
NilsBOP6d ago
thank you, sorry, that's obvious to me now looking at the docs. I was looking for a config like that but somehow missed it. That's what happens when I do this late at night

Did you find this page helpful?