@@ -31,22 +31,22 @@ export async function openNextHandler(
3131 internalEvent : InternalEvent ,
3232 responseStreaming ?: StreamCreator ,
3333) : Promise < InternalResult > {
34+ const initialHeaders = internalEvent . headers ;
3435 // We run everything in the async local storage context so that it is available in the middleware as well as in NextServer
3536 return runWithOpenNextRequestContext (
36- { isISRRevalidation : internalEvent . headers [ "x-isr" ] === "1" } ,
37+ { isISRRevalidation : initialHeaders [ "x-isr" ] === "1" } ,
3738 async ( ) => {
38- if ( internalEvent . headers [ "x-forwarded-host" ] ) {
39- internalEvent . headers . host = internalEvent . headers [ "x-forwarded-host" ] ;
39+ if ( initialHeaders [ "x-forwarded-host" ] ) {
40+ initialHeaders . host = initialHeaders [ "x-forwarded-host" ] ;
4041 }
4142 debug ( "internalEvent" , internalEvent ) ;
4243
4344 // These 2 will get overwritten by the routing handler if not using an external middleware
4445 const internalHeaders = {
4546 initialPath :
46- internalEvent . headers [ INTERNAL_HEADER_INITIAL_PATH ] ??
47- internalEvent . rawPath ,
48- resolvedRoutes : internalEvent . headers [ INTERNAL_HEADER_RESOLVED_ROUTES ]
49- ? JSON . parse ( internalEvent . headers [ INTERNAL_HEADER_RESOLVED_ROUTES ] )
47+ initialHeaders [ INTERNAL_HEADER_INITIAL_PATH ] ?? internalEvent . rawPath ,
48+ resolvedRoutes : initialHeaders [ INTERNAL_HEADER_RESOLVED_ROUTES ]
49+ ? JSON . parse ( initialHeaders [ INTERNAL_HEADER_RESOLVED_ROUTES ] )
5050 : ( [ ] as ResolvedRoute [ ] ) ,
5151 } ;
5252
0 commit comments