在electron-vue中配置跨域代理
对于下面问题解决: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. 跨域问题! 在electron-vue中配置跨域代理无效,经排查是因为在webpack中绕过了proxyTable,那么应该如何进行配置? 在.eltron-vue文件夹中又一个dev-runner.js文件,在WebpackDevServer中添加代理才能生效,因为版本或组件原因导致配置位置不同导致的 废话不多说,直接上代码了:dev-runner.js中修改 <pre class=”wp-block-code”><code> { contentBase: path.join(__dirname, ‘../’), quiet: true, proxy: { ‘/seller’: { // 请求的目标服务器地址 target: ‘http://192.168.3.107:8080’, // 设置允许跨域 changeOrigin: true, // 重写路径 pathRewrite: { ‘^/seller’: ‘/seller’ }, headers: { referer: ” } } }, before (app, ctx) { app.use(hotMiddleware) ctx.middleware.waitUntilValid(() => { resolve() }) } }</code></pre> 配置完成后记得重新run一遍 文章来源:田珊珊个人博客 来源地址:http://www.tianshan277.com/809.html
申请创业报道,分享创业好点子。点击此处,共同探讨创业新机遇!
本文素材来自互联网 (编辑:应用网_阳江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |