Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-http-proxy

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-http-proxy - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/app.js

13

package.json
{
"name": "express-http-proxy",
"version": "0.0.1",
"version": "0.1.0",
"description": "http proxy middleware for express",

@@ -27,6 +27,11 @@ "main": "index.js",

},
"devDependencies": {},
"devDependencies": {
"supertest": "^0.13.0",
"express": "^4.3.1"
},
"dependencies": {
"mocha": "^1.19.0"
"mocha": "^1.19.0",
"type-is": "^1.2.0",
"raw-body": "^1.1.6"
}
}
}
# express-http-proxy [![NPM version](https://badge.fury.io/js/express-http-proxy.svg)](http://badge.fury.io/js/express-http-proxy) [![Build Status](https://travis-ci.org/villadora/express-http-proxy.svg?branch=master)](https://travis-ci.org/villadora/express-http-proxy) [![Dependency Status](https://gemnasium.com/villadora/express-http-proxy.svg)](https://gemnasium.com/villadora/express-http-proxy)
<!-- description -->
Express proxy middleware to forward request to another host and pass response back
## Install

@@ -14,5 +15,47 @@

```js
var express_http_proxy = require('express-http-proxy');
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
```js
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:
```js
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

@@ -19,0 +62,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc