
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
express-http-proxy
Advanced tools
Express proxy middleware to forward request to another host and pass response back
$ npm install express-http-proxy --save
var proxy = require('express-http-proxy');
var app = require('express')();
app.use('/proxy', proxy('www.google.com', {
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
}
}));
If you only want to proxy get request
app.use('/proxy', proxy('www.google.com', {
filter: function(req, res) {
return req.method == 'GET';
},
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
}
}));
You can also intercept the response before sending it back to the client, or change the request options before it is sent to the target:
app.use('/proxy', proxy('www.google.com', {
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
},
intercept: function(rsp, data, req, res, callback) {
// rsp - original response from the target
data = JSON.parse(data.toString('utf8'));
callback(null, JSON.stringify(data));
},
decorateRequest: function(req) {
req.headers['Content-Type'] = '';
req.method = 'GET';
req.bodyContent = wrap(req.bodyContent);
return req;
}
}));
| Release | Notes |
|---|---|
| 0.4.0 | Signature of intercept callback changed from function(data, req, res, callback) to function(rsp, data, req, res, callback) where rsp is the original response from the target |
MIT
http-proxy-middleware is a popular middleware for creating proxies in Express.js. It offers more advanced features like path rewriting, logging, and WebSocket support. Compared to express-http-proxy, it provides more flexibility and is more actively maintained.
node-http-proxy is a low-level HTTP proxy library for Node.js. It provides a lot of customization options and can be used to create complex proxy servers. While it is more powerful, it requires more setup and configuration compared to express-http-proxy.
express-proxy is another middleware for proxying HTTP requests in Express.js. It is simpler and less feature-rich compared to express-http-proxy, making it suitable for basic proxying needs.
FAQs
http proxy middleware for express
The npm package express-http-proxy receives a total of 392,182 weekly downloads. As such, express-http-proxy popularity was classified as popular.
We found that express-http-proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.