Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
front-express-http-proxy
Advanced tools
Express proxy middleware to forward request to another host and pass response back
$ npm install express-http-proxy --save
proxy(host, options);
To proxy URLS starting with '/proxy' to the host 'www.google.com':
var proxy = require('express-http-proxy');
var app = require('express')();
app.use('/proxy', proxy('www.google.com'));
The forwardPath
option allows you to modify the path prior to proxying the request.
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;
}
}));
The filter
option can be used to limit what requests are proxied. For example, 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 intercept the response before sending it back to the client.
app.use('/proxy', proxy('www.google.com', {
intercept: function(rsp, data, req, res, callback) {
// rsp - original response from the target
data = JSON.parse(data.toString('utf8'));
callback(null, JSON.stringify(data));
}
}));
You can change the request options before it is sent to the target.
app.use('/proxy', proxy('www.google.com', {
decorateRequest: function(reqOpt, req) {
reqOpt.headers['Content-Type'] = '';
reqOpt.method = 'GET';
reqOpt.bodyContent = wrap(req.bodyContent);
return reqOpt;
}
}));
You can copy the host HTTP header to the proxied express server using the preserveHostHdr
option.
app.use('/proxy', proxy('www.google.com', {
preserveHostHdr: true
}));
Encoding used to decode request body. Default to utf-8
.
Use null
to avoid decoding and pass the body as is.
Accept any values supported by raw-body.
app.use('/post', proxy('httpbin.org', {
reqBodyEncoding: null
}));
A: Yes, you can use the 'https-proxy-agent' package. Something like this:
var corporateProxyServer = process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy;
if (corporateProxyServer) {
corporateProxyAgent = new HttpsProxyAgent(corporateProxyServer);
}
Then inside the decorateRequest method, add the agent to the request:
req.agent = corporateProxyAgent;
Release | Notes |
---|---|
0.7.2 | Collecting many minor documentation and test improvements. |
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
FAQs
http proxy middleware for express
The npm package front-express-http-proxy receives a total of 0 weekly downloads. As such, front-express-http-proxy popularity was classified as not popular.
We found that front-express-http-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.