- 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'
}
}
}
}
}