react http-proxy-middleware 代理没效果

#1

代理代码是这样的:

const proxy = require('http-proxy-middleware');
// import proxy from 'http-proxy-middleware';
module.exports = function (app) {
  app.use(
    proxy('/api', {
      target: 'http://localhost:9781/',
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    })
  );
};

请求的 URL:http://localhost:3000/api/login

但没有跳转到我代理的URL上
求大佬解疑

#2

老哥 你解决了吗?