Skip to content

Commit 42cee16

Browse files
Merge PR #2386: update sample app
2 parents 03cc83d + b67390c commit 42cee16

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/with-next-intl/middleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ export async function middleware(request: NextRequest) {
3434
}
3535
}
3636
// 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);
37+
// append them to intlRes. The append() method adds the header if it doesn't exist,
38+
// 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);
3942
}
4043

4144
return intlRes

0 commit comments

Comments
 (0)