Skip to content

Commit 87ed97d

Browse files
authored
Use Electron fetch or Node fetch for github-authentication to support proxies (microsoft#238149)
* Attempt to use Electron fetch for github-authentication Also changes fallback from node-fetch to the built-in Node fetch * Remove Content-Length header Electron compatibility It looks like it was set incorrectly to the body contents anyways.
1 parent a821bbf commit 87ed97d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

extensions/github-authentication/src/flows.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ async function exchangeCodeForToken(
105105
headers: {
106106
Accept: 'application/json',
107107
'Content-Type': 'application/x-www-form-urlencoded',
108-
'Content-Length': body.toString()
109-
110108
},
111109
body: body.toString()
112110
});

extensions/github-authentication/src/node/fetch.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
import fetch from 'node-fetch';
65

7-
export const fetching = fetch;
6+
let _fetch: typeof fetch;
7+
try {
8+
_fetch = require('electron').net.fetch;
9+
} catch {
10+
_fetch = fetch;
11+
}
12+
export const fetching = _fetch;

0 commit comments

Comments
 (0)