I have set up the reverse proxy with the angular2 CLI like the following:
{
"/api/customer/*": {
"target": "http://localhost:9010",
"secure": false
}
}
My problem is that the remote API is exposing a service on the path /customer, but the request that is sent by the reverse proxy is on /api/customer.
Is there a way to remove the /api from the request that is sent by the reverse proxy? (Don't answer with "just remove the /api from your http request", because I have an angular route on /customer).
You can do this fairly easy, using the pathRewrite
option like so:
proxy: {
'/api/customer/*': {
target: 'http://localhost:9010',
pathRewrite: {'^/api' : ''}
}
}
You can also take a look at the Updated Webpack documentation for further information.
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