From 25a2f00f14290e23888321464c310b81036fe42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Mon, 5 Aug 2019 09:12:07 +0200 Subject: [PATCH] Only removes the authorization header when switching hostnames (#334) --- packages/berry-core/sources/httpUtils.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/berry-core/sources/httpUtils.ts b/packages/berry-core/sources/httpUtils.ts index 9dfd78fb91c8..02e27abbe258 100644 --- a/packages/berry-core/sources/httpUtils.ts +++ b/packages/berry-core/sources/httpUtils.ts @@ -60,11 +60,17 @@ async function request(target: string, body: Body, {configuration, headers, json : globalHttpsAgent; const gotOptions = {agent, body, headers, json, method, encoding: null}; + let hostname: string | undefined; const makeHooks = () => ({ + beforeRequest: [ + (options: GotOptions) => { + hostname = options.hostname; + }, + ], beforeRedirect: [ (options: GotOptions) => { - if (options.headers && options.headers.authorization) { + if (options.headers && options.headers.authorization && options.hostname !== hostname) { delete options.headers.authorization; } },