"Error: 'c.header is not a function' in Hono setCookie with tRPC Integration"

I'm encountering an error in my Hono and tRPC setup when attempting to set a cookie after user registration. The error message is:
TypeError: c.header is not a function. (In 'c.header("Set-Cookie", cookie, { append: !0 })', 'c.header' is undefined)

const t = initTRPC.context<Context>().create();

const publicProcedure = t.procedure;
const router = t.router;

export const authRouter = router({
  register: publicProcedure.mutation(async ({ ctx }) => {
    const token = "exampleToken"; // Example token generation

    setCookie(ctx, "token", token, {
      path: "/",
      secure: process.env.NODE_ENV === "production",
      httpOnly: true,
      maxAge: 60 * 60 * 24 * 30,
      sameSite: "Lax",
    });
    
    return { message: "Registration successful!" };
  }),
});
Was this page helpful?