我正在使用 Electron 在 Windows 上编写桌面应用程序。现在我需要使用系统全局代理设置作为我自己的代理,同时使用请求来获取这样的数据
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) => {
});
那么,如何获取系统全局代理设置并将其分配给 this.proxyRequestUrl?
最佳答案
如果您从渲染器进行 http 调用,它将使用系统默认的代理设置。
如果您需要从主进程进行 http 调用,您可以使用 electron-remote remote-ajax-module这将通过渲染器进程进行调用。
您还可以使用 electron-fetch
在主进程中,它将使用系统代理设置。
关于node.js - 如何在 Node js 中获取系统代理设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42792669/