Skip to content

Commit 25a2f00

Browse files
authored
Only removes the authorization header when switching hostnames (#334)
1 parent 883927b commit 25a2f00

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/berry-core/sources/httpUtils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ async function request(target: string, body: Body, {configuration, headers, json
6060
: globalHttpsAgent;
6161

6262
const gotOptions = {agent, body, headers, json, method, encoding: null};
63+
let hostname: string | undefined;
6364

6465
const makeHooks = <T extends string | null>() => ({
66+
beforeRequest: [
67+
(options: GotOptions<T>) => {
68+
hostname = options.hostname;
69+
},
70+
],
6571
beforeRedirect: [
6672
(options: GotOptions<T>) => {
67-
if (options.headers && options.headers.authorization) {
73+
if (options.headers && options.headers.authorization && options.hostname !== hostname) {
6874
delete options.headers.authorization;
6975
}
7076
},

0 commit comments

Comments
 (0)