在electron中实现跨域请求
1、问题表述:xhr.js?b50d:160 OPTIONS http://192.168.20.24:9999/api/pacs/image/cpa?studyGUID=414114869864960000VM933:1 Failed to load http://192.168.20.24:9999/api/pacs/image/cpa?studyGUID=414114869864960...
·
1、问题表述:
xhr.js?b50d:160 OPTIONS http://192.168.20.24:9999/api/pacs/image/cpa?studyGUID=414114869864960000
VM933:1 Failed to load http://192.168.20.24:9999/api/pacs/image/cpa?studyGUID=414114869864960000: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9080' is therefore not allowed access.
2、解决方案:在Electron的BrowserWindow模块中配置这样一个参数:
mainWindow = new BrowserWindow({
webPreferences: {webSecurity: false},
})
3、说明
webSecurityBoolean (可选) - 当设置为false, 它将禁用同源策略 (通常用来测试网站), 如果此选项不是由开发者设置的,还会把allowRunningInsecureContent设置为true. 默认值为true。
allowRunningInsecureContentBoolean (可选) -允许一个 https 页面运行 http url 里的资源,包括 JavaScript, CSS 或 plugins. 默认值为false.
更多推荐

所有评论(0)