Hono tRPC Server body issue
I have been trying to get Cloudflare Workers, Hono and tRPC working for tens of hours now.
I am using the
@hono/trpc-server package which gives me middleware for trpc to run with hono. They even have an example with cloudflare workers and a d1 database, so I know it is possible to do what I am trying to do.
The problem I am having is that tRPC is not reading the body properly, or at all. Take this function as an example:
It never even gets to the mutation part at all because validation fails. Using errorFormatting with tRPC shows me that input is undefined when getting passed by postman, which is weird because I am definitely sending a title. It all worked before when I hadn't moved to Cloudflare Workers and before I was using the hono trpc-server package.
This is how I serve the app:
Here is some more context so you can understand my code a little better.
context.ts
How can I get tRPC to start recognizing the input? The context and database queries work as intended, it's just the input that is not working.6 Replies
can you share your client code as well?
Just using postman right now for testing
example:
POST to http://localhost:8787/trpc/quest.create
application/json
raw:
does the request have a body before it hits
trpcServer?Sorry for the wait,
Yeah I tried making this little debugger to see what was getting through
It returned:
weird. so all the routing is fine, and the data is there, but somehow it's not getting to the procedure handler
i've got no idea. i don't use
trpc though
ig you could try making a call with app.request, just in case there's something funky going on w postman, but doesn't seem like that's itYeah, super weird issue. I might just change my stack all together to avoid these headaches