Answer by Chukwuemeka Maduekwe for Can't set a cookie using NextJS 9's API Route
I just found an easier way to do this in Next.js, though with a library -- cookie-nextrun npm install --save cookies-nextIf you are using next.js version greater than 12.2.0 you need to use...
View ArticleAnswer by Kevin Law for Can't set a cookie using NextJS 9's API Route
Adapted from offical repo middleware example, you can set Set-Cookie header via res like so:import { serialize } from 'cookie';function (req, res) { // ... // setHeader(headerName: string, cookies:...
View ArticleCan't set a cookie using NextJS 9's API Route
Typically it seems that when using Express, in the "res" object there is "cookie" so you can do something like:res.cookie('session', sessionCookie, options);In the API routes offered by NextJS in Next...
View Article