# intercept-proxy

> A light weight proxy for exposing a remote site through localhost and replace select resources with local versions for testing and development purposes.

Latest version **0.3.3** (published 2013-03-11) · 0 weekly downloads

## Install

```sh
npm install intercept-proxy
pnpm add intercept-proxy
yarn add intercept-proxy
bun add intercept-proxy
```

Provides the command `intercept-proxy`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2013-03-11 |
| First published | 2012-08-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Maintainers | johanobrink |

## Links

- npm: https://www.npmjs.com/package/intercept-proxy
- Repository: https://github.com/JohanObrink/intercept-proxy
- Issues: https://github.com/JohanObrink/intercept-proxy/issues
- npm.io page: https://npm.io/package/intercept-proxy

## Dependencies (3)

- [mkdirp](https://npm.io/package/mkdirp.md) 0.3.3
- [commander](https://npm.io/package/commander.md) 0.6.1
- [underscore](https://npm.io/package/underscore.md) >=1.3.3

## Recent versions

- 0.3.3 (latest) — 2013-03-11
- 0.3.2 — 2013-03-11
- 0.3.1 — 2012-10-26
- 0.3.0 — 2012-10-24
- 0.2.4 — 2012-10-19
- 0.2.3 — 2012-10-18
- 0.2.2 — 2012-10-18
- 0.2.1 — 2012-10-18
- 0.2.0 — 2012-10-18
- 0.1.8 — 2012-08-30
- 0.1.7 — 2012-08-29
- 0.1.6 — 2012-08-27
- 0.1.5 — 2012-08-24
- 0.1.4 — 2012-08-24
- 0.1.3 — 2012-08-24
- … 3 more at https://npm.io/package/intercept-proxy/versions

## README

#Intercept Proxy [![Build Status](https://secure.travis-ci.org/JohanObrink/intercept-proxy.png?branch=master)](http://travis-ci.org/JohanObrink/intercept-proxy)
-
A lite-weight proxy for exposing a remote site through localhost and replace select resources with local versions for testing and development purposes.

##Install

    npm install intercept-proxy

##CLI
To use command line, you must first install package with

    npm install -g intercept-proxy

This is just done once. Then you can call:

    intercept-proxy myremote -h myremotesite.com -p 3000
    cd myremote
    npm install
    npm start

...and the site will runat http://localhost:3000 and point to myremotesite.com

##Usage
By pointing the proxy server at a url and running the app, you can surf the targeted site through localhost:

    var proxy = require('intercept-proxy');
    var server = proxy.createServer('knowyourmeme.com');
    server.listen(1337, function() {
      console.log('Proxy: ' + server.host + ' listening on http://localhost:' + server.port);
    });

or with more options:

    proxy.createServer({
      host: 'knowyourmeme.com',
      methods: 'GET,POST',           // will intercept GET and POST but not PUT and DELETE
      supressQuery: true             // remove query parameters from url when looking for local file
    });

##Intercepting with locals
By adding files to /local/[path], those files will replace the ones from the original site. Only GET requests will be intercepted by default.

    /js/main.js can be replaced by creating /local/js/main.js

###Controlling headers for local intercepts
intercept-proxy adds headers by default for common resource extensions such as css, js, html, aspx, php. If you need to control the headers, add a file called headers.json in the folder under local. All properties in the json object will be added as headers. If a default header is specified in headers.json, this will be overridden.

##Intercepting with handlers
Calls can also be intercepted using handlers. A handler can be registered with just path or path and verbs

    // register handler which responds to all calls to /foo/bar
    proxy.addHandler('/foo/bar', function(req, res) {
      res.end('foo');
    });

    //register handler which responds to POSTs and PUTs to /foo/bar
    proxy.addHandler('/foo/bar', 'POST,PUT', function(req, res) {
      res.end('foo');
    });

    //remove handler for all verbs in requests for /foo/bar
    proxy.removeHandler('/foo/bar');

    //remove handler for GET and DELETE in requests for /foo/bar
    proxy.removeHandler('/foo/bar', 'GET,DELETE');

##Why?
Beacuse I needed it for a project :)

---
_Source: https://npm.io/package/intercept-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
