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?
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.
Select the Start button, then select Settings > Network & Internet > Proxy. Under Manual proxy setup, turn on Use a proxy server.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With