Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I get system proxy setting in node js

I'm writing a desktop application on windows with electron. Now I need to use the System global proxy setting as my own proxy while using request to get some data like this

    request({
        url: "http://ahdas.drnh.gov.tw/index.php",
        method: "POST",
        proxy: this.proxyRequestUrl,
        headers: {
            "User-Agent": this.mainWindow.webContents.session.getUserAgent(),
            "Accept": "application/json, text/javascript, */*; q=0.01",
            "Accept-Encoding": "gzip, deflate",
            "Cookie": cookies
        },
        form: {'act': 'Display/built/' + bookKey + "/" + postPageKey}
    }, (err, response, body) => {

    });

So, how can I get the System global proxy settings and assign that to this.proxyRequestUrl?

like image 560
zzm Avatar asked Mar 14 '17 17:03

zzm


People also ask

How do I find my proxy settings for npm?

This can be easily verified by running: npm config list. If there is proxy or https-proxy setting set in global config you have to use --global in the command to remove it.

How do I enable system proxy?

Select the Start button, then select Settings > Network & Internet > Proxy. Under Manual proxy setup, turn on Use a proxy server.


1 Answers

If you make http calls from the renderer it will use the systems default proxy settings.

If you need to make http calls from the main process you could use electron-remote remote-ajax-module which will make the calls through a renderer process.

You can also use electron-fetch in the main process and it'll use the system proxy settings.

like image 148
Tim Avatar answered Oct 04 '22 11:10

Tim