We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
今天打算快速使用vue-cli建立一个小应用用于测试,使用axios发送http请求,但是遇到了跨域问题,总结了一下,供以后开发时参考,相信对其他人也有用。
在vue.config.js里面的devServer的proxy加入如下设置。
// vue.config.js const tableauApi = 'https://tableau.proxy.web.yimian.com.cn/'; module.exports = { devServer: { proxy: { '/tableau': { target: tableauApi, changeOrigin: true, pathRewrite: { '^/tableau': '' }, }, }, }, };
上面的设置表示,把/tableau开头的api代理到https://tableau.proxy.web.yimian.com.cn/,并且去掉/tableau。比如/tableau/test1就会被代理到https://tableau.proxy.web.yimian.com.cn/test1。
/tableau
https://tableau.proxy.web.yimian.com.cn/
/tableau/test1
https://tableau.proxy.web.yimian.com.cn/test1
这里底层使用的是http-proxy-middleware插件。
// vue.config.js module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/test/tableau/dist/': '/' };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
概述
今天打算快速使用vue-cli建立一个小应用用于测试,使用axios发送http请求,但是遇到了跨域问题,总结了一下,供以后开发时参考,相信对其他人也有用。
vue-cli的跨域设置
在vue.config.js里面的devServer的proxy加入如下设置。
上面的设置表示,把
/tableau
开头的api代理到https://tableau.proxy.web.yimian.com.cn/
,并且去掉/tableau。比如/tableau/test1
就会被代理到https://tableau.proxy.web.yimian.com.cn/test1
。这里底层使用的是http-proxy-middleware插件。
后续
The text was updated successfully, but these errors were encountered: