Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch doesn't honor http_proxy and https_proxy envs #1

Open
bczhc opened this issue Nov 23, 2023 · 0 comments
Open

fetch doesn't honor http_proxy and https_proxy envs #1

bczhc opened this issue Nov 23, 2023 · 0 comments

Comments

@bczhc
Copy link

bczhc commented Nov 23, 2023

This results in GithubDownloader being very slow in China Mainland without a proper proxy! I can now only get it download through Cloudflare WARP (as it creates a virtual network interface directly).

A working example is to add a dispatcher on fetch:

import {ProxyAgent} from 'undici';

(async () => {
    const res = await fetch('https://api.ipify.org?format=json', {
        dispatcher: new ProxyAgent('http://127.0.0.1:16619')
    });
    const data = await res.json();
    // shows my proxy server's IP
    console.log(data);
})();

See https://stackoverflow.com/questions/72534539/node-js-18-3-native-fetch-request-with-a-proxy

Also: node-fetch/node-fetch#195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant