vue-dynamic-proxy
v1.0.7
Published
vue-dynamic-proxy,The vue dynamic proxy does not need to be restarted
Downloads
9
Maintainers
Readme
安装
npm install -D vue-dynamic-proxy
webpack4使用
vue.config.js 引入
const { after } = require('vue-dynamic-proxy')
function resolve(dir) {
return path.join(__dirname, dir)
}
// 配置
devServer: {
// 必须是绝对路径
after: after(resolve('proxy.config.js'))
},
webpack5使用
vue.config.js 引入
const { setupMiddlewares } = require('vue-dynamic-proxy')
function resolve(dir) {
return path.join(__dirname, dir)
}
// 配置
devServer: {
// 必须是绝对路径
setupMiddlewares: setupMiddlewares(resolve('proxy.config.js'))
},
proxy.config.js
module.exports = [
{
prefix: '/dev-api',
target: 'http://localhost:8081',
changeOrigin: true,
pathRewrite: {
'^/dev-api': '/prod-api'
}
},
{
prefix: '/api',
target: 'http://localhost:8989',
changeOrigin: true,
pathRewrite: {
'^/api': '/prod-api'
}
},
]