- vue2.x
config/index.js
proxyTable: {
'/api': {
target: 'http://localhost:3000/', // 请求的接口的域名
// secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
pathRewrite: {
'^/api': ''
}
}
},
- vue3.x
vue.config.js
module.exports = {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8080/',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': '/static/mock'
}
}
}
}
}