代理的配置

配置代理:


 安装   yarn add http-proxy-middleware


创建文件的路径 src/setupProxy.js

 

const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
    app.use('/api',  
        createProxyMiddleware({
            target: 'https://cnodejs.org/api/v1',
            changeOrigin: true,
            pathRewrite: {
                "^/api": "/"
            }
        }
        ));
}

 

posted @ 2020-02-26 22:26  冬冬先生  阅读(239)  评论(0编辑  收藏  举报