-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use node-fetch-native to fix warning from JBrowse CLI on node 21+ (#4318
- Loading branch information
Showing
8 changed files
with
23 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import fetch, { RequestInfo, RequestInit } from 'node-fetch' | ||
import { ProxyAgent } from 'proxy-agent' | ||
import { fetch } from 'node-fetch-native/node' | ||
import { createProxy } from 'node-fetch-native/proxy' | ||
|
||
const proxy = createProxy() | ||
|
||
// The correct proxy `Agent` implementation to use will be determined | ||
// via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars | ||
|
||
// https://github.com/unjs/node-fetch-native?tab=readme-ov-file#proxy-support | ||
export default function fetchWithProxy( | ||
url: RequestInfo, | ||
options: RequestInit = {}, | ||
) { | ||
const agent = new ProxyAgent() | ||
return fetch(url, { agent, ...options }) | ||
return fetch(url, { ...options, ...proxy }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters