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 {
148148 getFixedHeaders ( ) : OutgoingHttpHeaders {
149149 // Do we want to apply this on writeHead?
150150 this . fixHeaders ( this . headers ) ;
151+ // This way we ensure that the cookies are correct
152+ this . headers [ SET_COOKIE_HEADER ] = this . _cookies ;
151153 return this . headers ;
152154 }
153155
@@ -178,16 +180,7 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
178180 this . fixHeaders ( this . headers ) ;
179181 if ( this . _cookies . length > 0 ) {
180182 // 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 ;
191184 }
192185
193186 if ( this . streamCreator ) {
You can’t perform that action at this time.
0 commit comments