Socket
Socket
Sign inDemoInstall

http-proxy-middleware

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy-middleware - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

.jscsrc

8

examples/browser-sync/index.js
/**
* Module dependencies.
*/
var browserSync = require('../../node_modules/browser-sync/index'); // require('browser-sync');
var browserSync = require('../../node_modules/browser-sync/index').create(); // require('browser-sync').create();
var proxyMiddleware = require('../../index'); // require('http-proxy-middleware');

@@ -15,3 +15,3 @@

browserSync({
browserSync.init({
server: {

@@ -21,4 +21,4 @@ baseDir: "./",

middleware: [proxy], // add the proxy to browser-sync
open: false
}
},
startPath: "/api"
});

@@ -25,0 +25,0 @@

@@ -113,4 +113,6 @@ var _ = require('lodash');

function proxyErrorLogger (err, req, res) {
var hostname = (req.hostname || req.host) || (req.headers && req.headers.host) // (node0.10 || node 4/5) || (websocket)
var targetUri = proxyOptions.target.host + req.url;
logger.error('[HPM] Proxy error: %s. %s -> "%s"', err.code, req.hostname, targetUri);
logger.error('[HPM] Proxy error: %s. %s -> "%s"', err.code, hostname, targetUri);
}

@@ -117,0 +119,0 @@

@@ -7,6 +7,8 @@ module.exports = {

var host = (req.headers && req.headers.host);
if (!res.headersSent) {
if (res.writeHead && !res.headersSent) {
res.writeHead(500);
}
res.end('Error occured while trying to proxy to: '+ host + req.url);
};
{
"name": "http-proxy-middleware",
"version": "0.9.0",
"version": "0.9.1",
"description": "The one-liner node.js proxy middleware for connect, express and browser-sync",

@@ -16,2 +16,3 @@ "main": "index.js",

"keywords": [
"reverse",
"proxy",

@@ -25,3 +26,6 @@ "middleware",

"gulp",
"websocket"
"grunt-contrib-connect",
"websocket",
"ws",
"cors"
],

@@ -35,19 +39,19 @@ "author": "Steven Chim",

"devDependencies": {
"browser-sync": "^2.8.2",
"chai": "^3.2.0",
"browser-sync": "^2.11.0",
"chai": "^3.4.1",
"connect": "^3.4.0",
"coveralls": "^2.11.4",
"coveralls": "^2.11.6",
"express": "^4.13.3",
"istanbul": "^0.3.19",
"istanbul": "^0.4.1",
"istanbul-coveralls": "^1.0.3",
"mocha": "^2.3.0",
"mocha-lcov-reporter": "0.0.2",
"ws": "^0.8.0"
"mocha": "^2.3.4",
"mocha-lcov-reporter": "1.0.0",
"ws": "^1.0.1"
},
"dependencies": {
"http-proxy": "^1.11.2",
"is-glob": "^2.0.0",
"http-proxy": "^1.12.0",
"is-glob": "^2.0.1",
"lodash": "^3.10.1",
"micromatch": "^2.2.0"
"micromatch": "^2.3.7"
}
}

@@ -5,8 +5,9 @@ # http-proxy-middleware

[![Coveralls](https://img.shields.io/coveralls/chimurai/http-proxy-middleware.svg?style=flat-square)](https://coveralls.io/r/chimurai/http-proxy-middleware)
[![Codacy](https://img.shields.io/codacy/43dc1adc5e4b490ca84a1f447c13795a.svg?style=flat-square)](https://www.codacy.com/app/chimurai/http-proxy-middleware/dashboard)
[![dependency Status](https://img.shields.io/david/chimurai/http-proxy-middleware.svg?style=flat-square)](https://david-dm.org/chimurai/http-proxy-middleware#info=dependencies)
[![devDependency Status](https://img.shields.io/david/dev/chimurai/http-proxy-middleware.svg?style=flat-square)](https://david-dm.org/chimurai/http-proxy-middleware#info=devDependencies)
The one-liner node.js proxy middleware for [connect](https://github.com/senchalabs/connect), [express](https://github.com/strongloop/express) and [browser-sync](https://github.com/BrowserSync/browser-sync)
Node.js proxying made simple. Configure proxy middleware with ease for [connect](https://github.com/senchalabs/connect), [express](https://github.com/strongloop/express) and [browser-sync](https://github.com/BrowserSync/browser-sync).
Powered by the popular Nodejitsu [`http-proxy`](https://github.com/nodejitsu/node-http-proxy). [![GitHub stars](https://img.shields.io/github/stars/nodejitsu/node-http-proxy.svg?style=social&label=Star)](https://github.com/nodejitsu/node-http-proxy)
## Install

@@ -31,3 +32,3 @@

```
* **context**: matches provided context against request-urls' path.
* **context**: matches provided context against request-urls' **path**.
Matching requests will be proxied to the target host.

@@ -126,3 +127,3 @@ Example: `'/api'` or `['/api', '/ajax']`. (more about [context matching](#context-matching))

// verbose api
proxyMiddleware('/', {target:'http://echo.websocket.org', ws: true});
proxyMiddleware('/', {target:'http://echo.websocket.org', ws:true});

@@ -247,2 +248,6 @@ // shorthand

## Recipes
View the [recipes](https://github.com/chimurai/http-proxy-middleware/tree/master/recipes) for common use cases.
## More Examples

@@ -258,3 +263,3 @@

Then run whichever example you want:
Run the example:

@@ -283,2 +288,5 @@ ```bash

```bash
# install dependencies
$ npm install
# unit tests

@@ -293,15 +301,5 @@ $ npm test

* [v0.9.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.9.0) - support subscribing to http-proxy proxyReq-event ([trbngr](https://github.com/trbngr)). Added logLevel and logProvider support.
* [v0.8.2](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.2) - fixed proxyError handler ([mTazelaar](https://github.com/mTazelaar))
* [v0.8.1](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.1) - fixed pathRewrite when `agent` is configured
* [v0.8.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.8.0) - support external websocket upgrade, fixed websocket shorthand
* [v0.7.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.7.0) - support shorthand syntax, fixed express/connect mounting
* [v0.6.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.6.0) - support proxyTable
* [v0.5.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.5.0) - support subscribing to http-proxy error- and proxyRes-event
* [v0.4.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.4.0) - support websocket
* [v0.3.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.3.0) - support wildcard / glob
* [v0.2.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.2.0) - support multiple paths
* [v0.1.0](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.1.0) - support path rewrite. deprecate proxyHost option
* [v0.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v0.0.5) - initial release
- [View changelog](https://github.com/chimurai/http-proxy-middleware/blob/master/CHANGELOG.md)
## License

@@ -312,20 +310,1 @@

Copyright (c) 2015 Steven Chim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@@ -119,3 +119,18 @@ var expect = require('chai').expect;

describe('faulty config. mixing classic with shorthand', function () {
var fn
beforeEach(function () {
result = configFactory.createConfig('http://localhost:3000/api', {target: 'http://localhost:8000'});
});
it('should use the target in the configuration as target', function () {
expect(result.options.target).to.equal('http://localhost:8000');
});
it('should not use the host from the shorthand as target', function () {
expect(result.options.target).not.to.equal('http://localhost:3000');
});
});
});

@@ -122,0 +137,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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