<commit_before># http-proxy-middleware

Middleware for [connect](https://github.com/senchalabs/connect) and [browser-sync](https://github.com/BrowserSync/browser-sync)

## Usage

### core concept
Create and configure the proxy middleware so it can be used as middleware in connect or browser-sync.
```javascript
var proxyMiddleware = require('http-proxy-middleware');

var proxy = proxyMiddleware(context, options);
```
* `context` path to proxy. Example: '/api'
* `options.target` target host to proxy to. (See "Options" for all options)


### browser-sync
Example: Proxy http://localhost:3000/ajax requests to http://cdnjs.cloudfare.com/ajax

```javascript
var browserSync = require('browser-sync');
var proxyMiddleware = require('http-proxy-middleware');

var cdnjsProxy = proxyMiddleware('/ajax', {target: 'http://cdnjs.cloudflare.com'});

browserSync({
    server: {
    	baseDir: "./",
    	port: 3000,
        middleware: [cdnjsProxy]
    }
});
```

### gulp + browser-sync
Example: Proxy http://localhost:3000/ajax requests to http://cdnjs.cloudfare.com/ajax

```javascript
var gulp = require('gulp');
var browserSync = require('browser-sync');
var proxyMiddleware = require('http-proxy-middleware');

gulp.task('serve', function () {
    var cdnjsProxy = proxyMiddleware('/ajax', {target: 'http://cdnjs.cloudflare.com'});
 
    browserSync({
        server: {
        	baseDir: "./",
        	port: 3000,
            middleware: [cdnjsProxy]
        }
    });
});
```

## Options

### options from [http-proxy](https://www.npmjs.com/package/http-proxy):

 *  **target**: url string to be parsed with the url module
 *  **forward**: url string to be parsed with the url module
 *  **agent**: object to be passed to http(s).request (see Node's [https agent](http://nodejs.org/api/https.html#https_class_https_agent) and [http agent](http://nodejs.org/api/http.html#http_class_http_agent) objects)
 *  **secure**: true/false, if you want to verify the SSL Certs
 *  **xfwd**: true/false, adds x-forward headers
 *  **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies)
 *  **hostRewrite**: rewrites the location hostname on (301/302/307/308) redirects.

## License:
The MIT License (MIT)

Copyright (c) 2015 <NAME>
<commit_msg>update README - connect example<commit_after># http-proxy-middleware

Middleware for [connect](https://github.com/senchalabs/connect) and [browser-sync](https://github.com/BrowserSync/browser-sync)

## Usage

### core concept
Create and configure the proxy middleware so it can be used as middleware in connect or browser-sync.
```javascript
var proxyMiddleware = require('http-proxy-middleware');

var proxy = proxyMiddleware(context, options);
```
* `context` path to proxy. Example: '/api'
* `options.target` target host to proxy to. (See "Options" for all options)


### browser-sync
Example: Proxy http://localhost:3000/ajax requests to http://cdnjs.cloudfare.com/ajax

```javascript
var browserSync = require('browser-sync');
var proxyMiddleware = require('http-proxy-middleware');

var cdnjsProxy = proxyMiddleware('/ajax', {target: 'http://cdnjs.cloudflare.com'});

browserSync({
    server: {
    	baseDir: "./",
    	port: 3000,
        middleware: [cdnjsProxy]
    }
});
```

### gulp + browser-sync
Example: Proxy http://localhost:3000/ajax requests to http://cdnjs.cloudfare.com/ajax

```javascript
var gulp = require('gulp');
var browserSync = require('browser-sync');
var proxyMiddleware = require('http-proxy-middleware');

gulp.task('serve', function () {
    var cdnjsProxy = proxyMiddleware('/ajax', {target: 'http://cdnjs.cloudflare.com'});
 
    browserSync({
        server: {
        	baseDir: "./",
        	port: 3000,
            middleware: [cdnjsProxy]
        }
    });
});

gulp.task('default', ['serve']);
```

## Options

### options from [http-proxy](https://www.npmjs.com/package/http-proxy):

 *  **target**: url string to be parsed with the url module
 *  **forward**: url string to be parsed with the url module
 *  **agent**: object to be passed to http(s).request (see Node's [https agent](http://nodejs.org/api/https.html#https_class_https_agent) and [http agent](http://nodejs.org/api/http.html#http_class_http_agent) objects)
 *  **secure**: true/false, if you want to verify the SSL Certs
 *  **xfwd**: true/false, adds x-forward headers
 *  **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies)
 *  **hostRewrite**: rewrites the location hostname on (301/302/307/308) redirects.

## License:
The MIT License (MIT)

Copyright (c) 2015 <NAME>

{'fraction_non_alphanumeric': 0.1564001747487986, 'fraction_numerical': 0.013979903888160769, 'mean_word_length': 4.144943820224719, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6451380', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1395, 'n_words': 393}