🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

express-http-proxy

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-http-proxy

http proxy middleware for express

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
626K
2.7%
Maintainers
1
Weekly downloads
 
Created
Source

express-http-proxy NPM version Build Status Dependency Status

Express proxy middleware to forward request to another host and pass response back

Install

$ npm install express-http-proxy --save

Usage

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 get by proxy before send it back to the client:

app.use('/proxy', proxy('www.google.com', {
  forwardPath: function(req, res) {
    return require('url').parse(req.url).path;
  },
  intercept: function(data, req, res, callback) {
       data = JSON.parse(data.toString('utf8'));
       callback(null, JSON.stringify(data.obj));
  }
}));

Licence

MIT

Keywords

express-http-proxy

FAQs

Package last updated on 28 May 2014

Did you know?

Socket

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.

Install

Related posts