Skip to content

Commit

Permalink
Only removes the authorization header when switching hostnames (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis authored Aug 5, 2019
1 parent 883927b commit 25a2f00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/berry-core/sources/httpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T extends string | null>() => ({
beforeRequest: [
(options: GotOptions<T>) => {
hostname = options.hostname;
},
],
beforeRedirect: [
(options: GotOptions<T>) => {
if (options.headers && options.headers.authorization) {
if (options.headers && options.headers.authorization && options.hostname !== hostname) {
delete options.headers.authorization;
}
},
Expand Down

0 comments on commit 25a2f00

Please sign in to comment.