Trying to rewrite path of request with http-proxy-middleware. But trouble is that when i am writing such code:
proxyMiddleware('/service/api', {target: 'http://192.168.70.99:8078/'});
It means that path like /service/api/export/1 will be redirected to http://192.168.70.99:8078/service/api/export/1; But I need to redirect it to http://192.168.70.99:8078/export/1. How can I do that?
You can pass the pathRewrite opiton and inside it use regex pattern to remove the path that you don't need:
proxyMiddleware('/service/api', {
  target: 'http://192.168.70.99:8078/',
  pathRewrite: {
    '^/service/api':'' //remove /service/api
  }
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With