http(s) proxy as connect middleware

npm install proxy-middleware
332 downloads in the last day
1 245 downloads in the last week
4 488 downloads in the last month

Build Status


var connect = require('connect')
  , url = require('url')
  , proxy = require('proxy-middleware')

var app = connect();
app.use('/api', proxy(url.parse('')));
// now requests to '/api/x/y/z' are proxied to ''



options allows any options that are permitted on the http or https request options.

Other options:

  • route: you can pass the route for connect middleware within the options, as well.
  • via: by default no via header is added. If you pass true for this option the local hostname will be used for the via header. You can also pass a string for this option in which case that will be used for the via header.

Usage with route:

var proxyOptions = url.parse('');
proxyOptions.route = '/api';

var middleWares = [proxy(proxyOptions) /*, ...*/];

// Grunt connect uses this method
npm loves you