How to set cookies from trpc backend using next.js

I need to set a cookie from the backend of trpc in next.js
2 Replies
Wrath
Wrath2y ago
You can pass the next response through the trpc context and set the cookie as a header
ctx.res.setHeader("Set-Cookie", cookie);
ctx.res.setHeader("Set-Cookie", cookie);
deviana
devianaOP2y ago
I got Type 'NextApiRequest' is not assignable to type 'never'.
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
const { req, res } = _opts;

return createInnerTRPCContext({ req, res });
};
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
const { req, res } = _opts;

return createInnerTRPCContext({ req, res });
};
I solved it Thanks @Wrath
Want results from more Discord servers?
Add your server