描述:
通过定义的参数,代理到proxy中target指向的地址。
vue.config.js
module.exports = {
devServer: {
proxy: {
// 配置跨域
'/api': {
target: "http://172.33.44.11:8081/rsdq",
ws:true,
changOrigin:true,
pathRewrite:{
'^/api':'/'
}
}
}
}
}
test.vue
// 这里的/api代理到了proxy中的target指向的地址
axios.post('/api/sysDict/addSysDict').then((res)=>{
})