Proxy Community
How to Modify the Request Path in a Node Express Proxy? Need Help with 'node express proxy change request path'! - Printable Version

+- Proxy Community (https://proxycommunity.com/forum)
+-- Forum: Technical Community Support (https://proxycommunity.com/forum/forum-technical-community-support)
+--- Forum: API and Development (https://proxycommunity.com/forum/forum-api-and-development)
+--- Thread: How to Modify the Request Path in a Node Express Proxy? Need Help with 'node express proxy change request path'! (/thread-how-to-modify-the-request-path-in-a-node-express-proxy-need-help-with-node-express-proxy-change-request-path)

Pages: 1 2 3


“” - stealthVoyX99 - 17-03-2025

Hey! I’ve been working on something similar. For node express proxy change request path, I used `http-proxy-middleware` with `pathRewrite`. Here’s a quick example:

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

app.use('/api', proxy({
target: 'http://your-server.com',
pathRewrite: { '^/api': '' }, // removes /api
}));
```

This should help you strip or modify the path. If you need more advanced stuff, you can even use a function in `pathRewrite` to handle dynamic changes.

Also, their GitHub page has a ton of examples. Definitely worth checking out!