不需要配置
具体理解参考https://www.cnblogs.com/bobo1/p/12588079.html
devServer: {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
‘/api’: {
target: http://10.24.4.214:8098/api
,
changeOrigin: true,
pathRewrite: {
‘^/api’ : ‘’
}
}
}
}
/api表示需要去匹配请求时的url,然后替换成target的值
比如你页面里是写的
axios.post(’/api/list/gd’)
最终node去请求后台的地址是:http://10.24.4.214:8098/api/list/gd
但是你在浏览器里看到的还是:http://localhost:8888/api/list/gd,这时候就不存在跨越的问题的,node服务已经代理拿到数据了
其实真正引起跨越问题是浏览器的安全机制