proxy - Electron 代理

标签 proxy electron

我有一个 Electron 应用程序,试图通过该应用程序从同一网络调用url,但是出于安全考虑,我考虑了使用代理的想法。

 function createWindow () {
  const mainWindow = new BrowserWindow({
    webPreferences: { webSecurity: false },
    width: 1024,
    height: 768,
  });

  mainWindow.webContents.session.setProxy({proxyRules: "https=192.168.3.242:8000" }, function () {
     mainWindow.loadURL('https://localhost:8000/');
  });
}

app.on('ready', createWindow);

但这似乎并不能解决问题。我的想法有效吗?知道我在做什么错吗?
谢谢

最佳答案

对于整个应用程序,您可以使用Electron支持的命令行开关:

const { app } = require('electron')
app.commandLine.appendSwitch('proxy-server', '172.17.0.2:3128')
app.on('ready', () => {
  // Your code here
})
参见documentation

关于proxy - Electron 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53536553/

相关文章:

http - 存储和转发带有重试的 HTTP 请求?

java - Android 7 - 以编程方式设置代理

javascript - 如何在 Electron 渲染器进程中使用 RxJs 等模块?

用于带代理支持的多线程蜘蛛的 Python 包?

proxy - Apache Traffic Server 中的完整集群

scala - 动态代理,无需在 scala 中显式指定类型

javascript - Electron 渲染器中的IPC从缺少的函数__dirname引发错误

angular - Bootstrap 4模式在 Electron 中不起作用

angular - Electron/Angular 应用程序可以访问文件夹中的视频。

electron - 突然程序白屏