We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 03cc83d + b67390c commit 42cee16Copy full SHA for 42cee16
examples/with-next-intl/middleware.ts
@@ -34,8 +34,11 @@ export async function middleware(request: NextRequest) {
34
}
35
36
// For all other headers, or if 'x-middleware-next' can be safely copied,
37
- // set them on intlRes. This ensures session cookies from authResponse are preserved.
38
- intlRes.headers.set(key, value);
+ // append them to intlRes. The append() method adds the header if it doesn't exist,
+ // or appends the value if it does. This correctly preserves multi-value headers
39
+ // like set-cookie. HTTP allows multiple headers with the same name, and using
40
+ // append() ensures all cookie values are preserved instead of overwriting.
41
+ intlRes.headers.append(key, value);
42
43
44
return intlRes
0 commit comments