diff --git a/source/core/index.ts b/source/core/index.ts index 28232a5fc..7973b1a33 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -2068,7 +2068,7 @@ export default class Request extends Duplex implements RequestEvents { decodeURI(redirectString); // Redirecting to a different site, clear sensitive data. - if (redirectUrl.hostname !== url.hostname) { + if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) { if ('host' in options.headers) { delete options.headers.host; } @@ -2088,6 +2088,10 @@ export default class Request extends Duplex implements RequestEvents { // @ts-expect-error delete options.password; } + + if ('port' in options) { + delete options.port; + } } this.redirects.push(redirectString);