美文网首页
在electron中实现跨域请求

在electron中实现跨域请求

作者: 逸笛 | 来源:发表于2021-11-23 16:33 被阅读0次

由于我在axios中设置了 withCredentials: false,导致cookie携带不了。
解决方案:在Electron的BrowserWindow模块中配置这样一个参数:

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



allowRunningInsecureContent Boolean (可选) -允许一个 https 页面运行 http url 里的资源,包括 JavaScript, CSS 或 plugins. 默认值为 false.

相关文章

网友评论

      本文标题:在electron中实现跨域请求

      本文链接:https://www.haomeiwen.com/subject/qzbwtrtx.html