chore: use node-fetch-native support for proxy env vars (#3483)

This commit is contained in:
Peter Evans 2024-11-04 12:59:34 +00:00 committed by GitHub
parent 6d751ce675
commit 0c478ad1a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 134 deletions

View file

@ -3,8 +3,7 @@ import {Octokit as OctokitCore} from '@octokit/core'
import {paginateRest} from '@octokit/plugin-paginate-rest'
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
import {throttling} from '@octokit/plugin-throttling'
import {getProxyForUrl} from 'proxy-from-env'
import {createFetch} from 'node-fetch-native/proxy'
import {fetch} from 'node-fetch-native/proxy'
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
// eslint-disable-next-line import/no-unresolved
export {OctokitOptions} from '@octokit/core/dist-types/types'
@ -36,9 +35,6 @@ export const throttleOptions = {
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
function autoProxyAgent(octokit: OctokitCore) {
octokit.hook.before('request', options => {
const proxy = getProxyForUrl(options.baseUrl)
if (proxy) {
options.request.fetch = createFetch(proxy)
}
options.request.fetch = fetch
})
}