1.安装 http-proxy-middleware

npm install http-proxy-middleware

2.在src目录下创建setupProxy.js,并加入以下代码

const proxy = require('http-proxy-middleware');
module.exports = function (app) {
    app.use(proxy('/api1', {
        target: "https://news.baidu.com/",
        pathRewrite: {'^/baidu': ''},
        changeOrigin: true
    }));
    app.use(proxy('/api2', {
        target: "https://www.fakin.cn/",
        pathRewrite: {'^/api': ''},
        changeOrigin: true
    }));
};

即可