1、安装http-proxy-middleware
$ npm install http-proxy-middleware --save
$ # or
$ yarn add http-proxy-middleware
2、创建一个setupProxy.js文件,在src目录,src/setupProxy.js
例如之前的配置
"proxy": {
  "/api": {
    "target": "http://localhost: 3000/"
    }
}setupProxy.js文件里则这样写
const proxy = require('http-proxy-middleware')
 
module.exports = function(app) {
  app.use(proxy('/api', { target: 'http://localhost: 3000/' }))
}完整的写法
app.use(proxy('/api', { 
target: 'https://localhost: 3000/',
changeOrigin:true,
pathRewrite: {
            "^/api": "/"
        }
}))                










