Next.js Multiple Set-Cookie in App Router's Router Handler Weird Behavior
Answered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
Setting multiple cookies in a response object in a route handler in Nextjs App Router works when testing locally, both
How do I achieve this when deploying it to vercel?
A minimal repo setup demonstrating the problem:
https://nextjs-cookie-test-jet.vercel.app/
https://github.com/BowangLan/nextjs-cookie-test
npm run dev and npm run build && npm run start . However, when I deployed to Vercel, multiple set cookies are concatenated into a single set cookie. How do I achieve this when deploying it to vercel?
A minimal repo setup demonstrating the problem:
https://nextjs-cookie-test-jet.vercel.app/
https://github.com/BowangLan/nextjs-cookie-test
Answered by Asiatic Lion
I solved this problem by setting the runtime to edge:
export const runtime = "edge";3 Replies
Asiatic LionOP
I solved this problem by setting the runtime to edge:
export const runtime = "edge";Answer
Asiatic LionOP
However, some libraries I'm using within this route does not support edge runtime!
How can I achieve setting multiple cookies in a route handler response?