Skip to content

[NEXT-471] Calling cookies.set twice sets only one value, in API route with Edge runtime #38302

Description

@eric-burel

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Not applicable, see reproduction here: https://codesandbox.io/s/condescending-torvalds-e3il3k?file=/package.json

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Calling "cookies.set" twice on an API route with edge handler runtime will set only one cookie.

Expected Behavior

You'll see one "Set-Cookie" with 2 values, however it should be instead 2 "Set-Cookie" with only one value.

Set-Cookie can be repeated as many time as needed in an HTTP response to set multiple cookies. Edge middlewares do not suffer from this issue, it affects only API routes.

Link to reproduction

https://codesandbox.io/s/condescending-torvalds-e3il3k

To Reproduce

https://codesandbox.io/s/condescending-torvalds-e3il3k?file=/pages/index.tsx
Open index, check the Network tab for the "cookie" request.

NEXT-471

Metadata

Metadata

Assignees

Labels

RuntimeRelated to Node.js or Edge Runtime with Next.js.bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions