Hono tRPC Server body issue
reddit.com·17h·
Discuss: r/node
Flag this post

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:

create: publicProcedure
.input(z.object({ title: z.string() }))
.mutation(async ({ ctx, input }) => {
console.error(input);
const quest = await ctx.db
.insertInto("quest")
.values(input)
.returningAll()
.executeTakeFirst();
return quest;
}),

It never even gets to the mutation part at all because validation fails. Using errorFormatting with tRPC shows me …

Similar Posts

Loading similar posts...