1.0.5 • Published 4 years ago

no-cors-proxy v1.0.5

Weekly downloads
4
License
ISC
Repository
-
Last release
4 years ago

no-cors-proxy

A simple http proxy that add cors header to server responses. Useful if you need to consume an API that doesn't allow cross origin requests.

Using as global module

$ npm install no-cors-proxy -g

$ no-cors-proxy -p 8000 -t http://some.api.com

After executing this command:

  • Each request to localhost on port 8000 will be forwarded to some.api.com on port 80
  • Responses from server will be provided with Access-Control-Allow-Origin: * http header
  • Each OPTIONS request (see: preflight request) will be replyed automatically by the proxy.
Available options:
  • -h host (default: localhost)
  • -p port (default: 3000)
  • -t target (default: localhost)

Using as local dependency

npm install no-cors-proxy --save

Then in your package.json launch the proxy before to start your app

"scripts": {
    "start": "node ./node_modules/no-cors-proxy/bin -t https://some.api.com | node my-app.js"
}

Using programmatically

npm install no-cors-proxy --save
const NoCorsProxy = require('no-cors-proxy');
const port = 8080;
const host = 'localhost';
const target = 'http://some.api.com';

const proxy = new NoCorsProxy(port, host, target)
proxy.start();
1.0.5

4 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago