Use Electron fetch or Node fetch for github-authentication to support proxies (#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.
pull/238163/head
Devraj Mehta 2025-01-17 14:05:10 -05:00 committed by GitHub
parent a821bbf97f
commit 87ed97df8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -105,8 +105,6 @@ async function exchangeCodeForToken(
headers: {
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': body.toString()
},
body: body.toString()
});

View File

@ -2,6 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import fetch from 'node-fetch';
export const fetching = fetch;
let _fetch: typeof fetch;
try {
_fetch = require('electron').net.fetch;
} catch {
_fetch = fetch;
}
export const fetching = _fetch;