devServer: {
host: '0.0.0.0',
port: port,
open: true,
before(app) {
app.use((req, res, next) => {
next()
})
},
proxy: {
[process.env.VUE_APP_BASE_API]: {
target: 'http://192.168.50.46:8085/',
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
},
'/api/cim-manage': {
target: 'http://50.50.147.69:10000/',
changeOrigin: true,
pathRewrite: {
'^/api/cim-manage': '/api/cim-manage'
},
onProxyReq: (proxyReq, req, res) => {
const hostHeader = proxyReq.getHeader('host')
const [host, port] = hostHeader.split(':')
console.log(`请求2: ${proxyReq.protocol}//${host}:${port || '80'}${proxyReq.path}`)
const originalUrl = req.originalUrl
console.log(`代理前请求: ${req.protocol}://${req.get('host')}${originalUrl}`)
},
onProxyRes: (proxyRes, req, res) => {
const port = proxyRes.req.socket && proxyRes.req.socket.remotePort
console.log(`代理2: ${proxyRes.req.protocol}//${proxyRes.req.host}:${port || '80'}${proxyRes.req.path}`)
}
}
},
disableHostCheck: true
}