在 vue.config.js 中配置
devServer: {
open: true,
host: "0.0.0.0", //接收所有的域名或者ip
port: 9527,
proxy: {
// https://x.dscmall.cn/api/goods/type_list?page=1&size=10&type=is_best
"/api": {
target: "https://x.dscmall.cn/api", // 代理的目标服务器地址
changeOrigin: true, //允许跨域访问
pathRewrite: { // 重写路径
"^/api": ""
}
}
}
}