vue项目中配置proxyTable
例如:本地服务器端口+IP: http://10.2.33.23:8081
请求接口 http://10.2.33.20:22008/ctm01ipac/tag/listAll
修改配置:config-->index.js
dev:{
//项目其他配置省略
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://10.2.33.20:22008', //代理的请求域名和端口
changeOrigin: true, //是否跨域
pathRewrite: {
'^/api': '/ctm01ipac', //重写
}
}
},
}
前端接口请求:
export function getLabelField(opts) {
return http.get('/api/tag/listAll', opts);
}