devServer: {
// port:8081, 如果出现404 可能你的8080端口被占用了,
// port换端口
proxy: {
'/api': {
target: 'http://124.223.211.67:8080',
chageOrigin: true,
pathRewrite: { '^/api': '' },//路径改写
},
}
}
代理(反向代理)
什么是跨域:协议,域名,端口号不同请求,称之为跨域
例:http://localhost:8000/#/home —前端项目的本地服务器
http://39.98.123.211 —调取数据的后台服务器
直接调取后台服务器数据的话,会出现404
在vue.config.js中写