This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +6
-5
lines changed Expand file tree Collapse file tree 4 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -405,7 +405,6 @@ export class ServiceWorkerGlobalScope extends WorkerGlobalScope {
405405 }
406406 }
407407
408- request . headers . delete ( "host" ) ;
409408 // noinspection ES6MissingAwait
410409 const waitUntil = Promise . all ( event [ kWaitUntil ] ) as Promise < WaitUntil > ;
411410 return withWaitUntil ( await fetch ( request [ kInner ] ) , waitUntil ) ;
Original file line number Diff line number Diff line change @@ -87,6 +87,9 @@ export async function convertNodeRequest(
8787 req . headers [ "cf-ray" ] ??= randomHex ( 16 ) ;
8888 req . headers [ "cf-visitor" ] ??= `{"scheme":"${ proto } "}` ;
8989
90+ // Make sure we're using the correct host header (with custom upstream)
91+ req . headers [ "host" ] = url . host ;
92+
9093 // Build Headers object from request
9194 const headers = new Headers ( ) ;
9295 for ( const [ name , values ] of Object . entries ( req . headers ) ) {
Original file line number Diff line number Diff line change @@ -102,10 +102,12 @@ function request(
102102}
103103
104104test ( "convertNodeRequest: uses request url, with upstream or host as base" , async ( t ) => {
105- let [ , url ] = await buildConvertNodeRequest ( t , {
105+ // eslint-disable-next-line prefer-const
106+ let [ request , url ] = await buildConvertNodeRequest ( t , {
106107 path : "/test" ,
107108 upstream : "http://upstream.com" ,
108109 } ) ;
110+ t . is ( request . headers . get ( "host" ) , "upstream.com" ) ;
109111 t . is ( url . toString ( ) , "http://upstream.com/test" ) ;
110112
111113 [ , url ] = await buildConvertNodeRequest ( t , { path : "/test" } ) ;
Original file line number Diff line number Diff line change @@ -16,9 +16,6 @@ export async function upgradingFetch(
1616) : Promise < Response > {
1717 const request = new Request ( input , init ) ;
1818
19- // Cloudflare ignores request Host
20- request . headers . delete ( "host" ) ;
21-
2219 // Handle web socket upgrades
2320 if (
2421 request . method === "GET" &&
You can’t perform that action at this time.
0 commit comments