VUE-cli 3.0中的proxy使用方法
devServer: {
proxy: {
'/api': {
target: 'http://192.168.1.22:18308',
ws: true,
secure: false,
changeOrigin: true,
pathRewrite:{
'^/api':''
}
}
}
}
VUE-cli 2.0 中的proxy使用方法
proxyTable: {
"/api": {
target: "http://192.168.1.22:18308",
pathRewrite: {
'^/api': '/'
},
changeOrigin: true
},
},
proxy具体的一些其他的小细节
dev.env.js
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
ADMIN_SERVER: '"/api/"',
})
config - index.js
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
"/api": {
target: "http://192.168.1.22:18308",
pathRewrite: {
'^/api': '/'
},
changeOrigin: true
},
},
config - prod.env.js
'use strict'
module.exports = {
NODE_ENV: '"production"',
BASE_API: '"http://202.175.236.125:18308"'
}