electron接口跨域解决

3 min read

electron接口跨域解决

webSecurity Boolean (可选) - 当设置为 false, 它将禁用同源策略 (通常用来测试网站), 如果此选项不是由开发者设置的,还会把 allowRunningInsecureContent设置为 true. 默认值为 true。

我们只需要在主进程的 new BrowserWindow() 方法中添加

webPreferences: {
   webSecurity: false
}

就可以了