How can I get the system proxy setting in node js

I am writing a desktop application on windows with an electron. Now I need to use the System global proxy setting as my own proxy, using a query 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 global proxy settings of the system and assign this to this.proxyRequestUrl?

+7
source share
1 answer

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

If you need to make http calls from the main process, you can use a remote electronic-remote ajax module that will make calls through the renderer process.

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

0
source

Source: https://habr.com/ru/post/1265444/


All Articles