Giter Site home page Giter Site logo

cors-proxy's Introduction

Deploy

CORS Proxy

This simple Node.js-based proxy allows your JavaScript application to call services that are hosted on a different domain and that don't support CORS.

Because the proxy is itself CORS-enabled, your application and the proxy don't have to be hosted on the same domain.

This proxy was tested with the Salesforce.com REST API, but it should work with other services as well.

Installation

There are different options to get your own instance of the CORS proxy up and running:

  1. Deploy to Heroku (easiest): click the 'Deploy to Heroku' button at the top of this page

  2. Install a local version

    • Clone this repository

    • Install the server dependencies

      npm install
      
    • Start the server

      node server
      

Usage

When making an API call using JavaScript (using XMLHTTPRequest, $.ajax, etc):

  1. Substitute the actual service URL with the Proxy URL

  2. Set the request method, query parameters, and body as usual

  3. Set the actual service URL in a header named 'Target-Endpoint'

  4. Send the request as usual

CORS Headers

The proxy allows all origins, methods, and headers. You probably want to lock this down in a production environment.

Other Headers

The proxy currently passes the "Authorization" header to the target endpoint. You can modify the proxy to pass additional headers (or all of them).

Other Implementations

Check out James Ward's Saleforce CORS Proxy written in Scala.

cors-proxy's People

Contributors

ccoenraets avatar toddhalfpenny avatar

Watchers

James Cloos avatar

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.