Coder Social home page Coder Social logo

no-cors-proxy's Introduction

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();

no-cors-proxy's People

Contributors

emanuelelongo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

netlopa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.