Created
August 14, 2024 13:55
-
-
Save nphmuller/8643b0e162885c985255a9aae6d9420b to your computer and use it in GitHub Desktop.
next set-cookie edge issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function copyHeaders() { | |
const headers = new Headers(); | |
headers.append("set-cookie", "cookie1=value1"); | |
headers.append("set-cookie", "cookie2=value2"); | |
const response = new Response(undefined, { headers }); | |
console.log( | |
`before (length ${headers.getSetCookie().length}): `, | |
headers.getSetCookie() | |
); | |
console.log( | |
`after (length ${response.headers.getSetCookie().length}): `, | |
response.headers.getSetCookie() | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In a page component (or layout etc, Node runtime is important here) there are 2 set-cookie headers in the response.
In a middleware (edge runtime) there will be 2 in "headers" and only 1 in "response".
Evens stranger, the 1 set-cookie header in "response" now contains a single invalid value:
'cookie1=value1, cookie2=value2'
.After upgrading to [email protected] the issue is fixed and there are always 2 set-cookie headers.