Skip to content

fetch doesn't honor http_proxy and https_proxy envs #1

@bczhc

Description

@bczhc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions