UNPKG

1.04 kBMarkdownView Raw
1[![Build Status](https://secure.travis-ci.org/superjoe30/connect-proxy.png)](http://travis-ci.org/superjoe30/connect-proxy)
2
3### Usage:
4
5```js
6var connect = require('connect')
7 , url = require('url')
8 , proxy = require('proxy-middleware')
9
10var app = connect();
11app.use('/api', proxy(url.parse('https://example.com/endpoint')));
12// now requests to '/api/x/y/z' are proxied to 'https://example.com/endpoint/x/y/z'
13```
14
15### Documentation:
16
17`proxyMiddleware(options)`
18
19`options` allows any options that are permitted on the [`http`](http://nodejs.org/api/http.html#http_http_request_options_callback) or [`https`](http://nodejs.org/api/https.html#https_https_request_options_callback) request options.
20
21Other options:
22- `route`: you can pass the route for connect middleware within the options, as well.
23
24### Usage with route:
25
26```js
27var proxyOptions = url.parse('https://example.com/endpoint');
28proxyOptions.route = '/api';
29
30var middleWares = [proxy(proxyOptions) /*, ...*/];
31
32// Grunt connect uses this method
33connect(middleWares);
34```