A simple JSON proxy
Clone or download

README.md

JSONProxy Build Status

Simple HTTP proxy that enables cross-domain requests to any JSON API. See https://jsonp.afeld.me for documentation. See the releases page for the client library changelog.

Setup

Simple

See package.json for compatible Node versions.

npm install
npm start

and do requests to http://localhost:8000/?url=.... For live reloading:

npm install -g nodemon
export $(cat .env | xargs) && nodemon

Deploy

Docker

  1. Ensure Docker is installed and running.
  2. Run touch .env
    • Optionally fill out with environment variables specified above.
  3. Start the server with docker-compose up.
    • If you make a change and need to re-build, just press CTRL-c and run again.
  4. Visit http://localhost.

Deployment

This app is deployed to AWS with the Serverless Framework. To deploy, run

sls create_domain
sls deploy

If you use the client library with your own JSONP deployment, override the proxy URL before calling $.jsonp().

$.jsonp.PROXY = 'https://mydomain.com/proxy/path/';

Rate limiting

Do the following to set up an nginx proxy for rate limiting the requests.

  1. Get a CloudFlare API key.

  2. Go into the terraform/ directory.

    cd terraform
  3. Create a terraform.tfvars file.

    cloudflare_email = "..."
    cloudflare_token = "..."
  4. Deploy the environment.

    terraform init
    terraform apply

See also