UncleBen
Explore posts from serversTTCTheo's Typesafe Cult
•Created by UncleBen on 1/6/2024 in #questions
Unable to use setHeader on response object from trpc context (using app router)
I'm trying to set a JWT cookie in a login mutation in a router, here's the code snippet I'm using to try set the token
ctx.res.setHeader(
"Set-Cookie",
cookie.serialize("user-token", token, {
httpOnly: true,
path: "/",
secure: env.NODE_ENV === "production",
}),
);
however in the console I receive this error ❌ tRPC failed on auth.login: Cannot read properties of undefined (reading 'setHeader') would anyone else happen to be knowledgeable on this thanks3 replies