@@ -41,15 +41,16 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
4141 } ) : Writable {
4242 const { statusCode, cookies, headers } = prelude ;
4343
44- const responseHeaders = new Headers ( headers ) ;
45- for ( const cookie of cookies ) {
46- responseHeaders . append ( "Set-Cookie" , cookie ) ;
47- }
48-
4944 // TODO(vicb): this is a workaround to make PPR work with `wrangler dev`
5045 // See https://github.com/cloudflare/workers-sdk/issues/8004
5146 if ( url . hostname === "localhost" ) {
52- responseHeaders . set ( "Content-Encoding" , "identity" ) ;
47+ headers [ "content-encoding" ] = "identity" ;
48+ }
49+
50+ // Build headers array - set-cookie must be added separately for each cookie
51+ const headerEntries : [ string , string ] [ ] = Object . entries ( headers ) ;
52+ for ( const cookie of cookies ) {
53+ headerEntries . push ( [ "set-cookie" , cookie ] ) ;
5354 }
5455
5556 const { readable, writable } = new TransformStream ( {
@@ -60,7 +61,7 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
6061 const body = NULL_BODY_STATUSES . has ( statusCode ) ? null : readable ;
6162 const response = new Response ( body , {
6263 status : statusCode ,
63- headers : responseHeaders ,
64+ headers : headerEntries ,
6465 } ) ;
6566 resolveResponse ( response ) ;
6667
0 commit comments