File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
packages/open-next/src/http Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " open-next " : patch
3
+ ---
4
+
5
+ Fix duplicate cookies
Original file line number Diff line number Diff line change @@ -148,6 +148,8 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
148
148
getFixedHeaders ( ) : OutgoingHttpHeaders {
149
149
// Do we want to apply this on writeHead?
150
150
this . fixHeaders ( this . headers ) ;
151
+ // This way we ensure that the cookies are correct
152
+ this . headers [ SET_COOKIE_HEADER ] = this . _cookies ;
151
153
return this . headers ;
152
154
}
153
155
@@ -178,16 +180,7 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
178
180
this . fixHeaders ( this . headers ) ;
179
181
if ( this . _cookies . length > 0 ) {
180
182
// For cookies we cannot do the same as for other headers
181
- // We need to merge the cookies, and in this case, cookies generated by the routes or pages
182
- // should be added after the ones generated by the middleware
183
- // This prevents the middleware from overriding the cookies, especially for server actions
184
- // which uses the same pathnames as the pages they're being called on
185
- this . headers [ SET_COOKIE_HEADER ] = [
186
- ...( parseCookies (
187
- this . initialHeaders ?. [ SET_COOKIE_HEADER ] as string | string [ ] ,
188
- ) ?? [ ] ) ,
189
- ...this . _cookies ,
190
- ] ;
183
+ this . headers [ SET_COOKIE_HEADER ] = this . _cookies ;
191
184
}
192
185
193
186
if ( this . streamCreator ) {
You can’t perform that action at this time.
0 commit comments