[b]"How to Modify the Request Path in a Node Express Proxy? Need Help with 'node express proxy change request path'!"[/b

10 Replies, 1797 Views

Hey! If you’re looking to dynamically change the request path in a node express proxy, `http-proxy-middleware` is your best bet. Here’s a quick example:

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

app.use('/api', createProxyMiddleware({
target: 'http://your-target-server.com',
pathRewrite: function (path, req) {
return path.replace('/api/v1', '/v2');
}
}));
```
This will handle the node express proxy change request path issue easily. Let me know if you run into any problems!



Users browsing this thread: 1 Guest(s)