Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/afeld/jsonp

DEPRECATED - A proxy to help with cross-domain requests
https://github.com/afeld/jsonp

Last synced: about 2 months ago
JSON representation

DEPRECATED - A proxy to help with cross-domain requests

Awesome Lists containing this project

README

        

***The hosting for jsonp.afeld.me became too expensive to pay out of pocket, so I have decided to shut this down. Glad so many people found it useful over the years!***

---

# JSONProxy [![Tests](https://github.com/afeld/jsonp/actions/workflows/main.yml/badge.svg)](https://github.com/afeld/jsonp/actions/workflows/main.yml)

HTTP proxy that enables cross-domain requests to any JSON API. See https://jsonp.afeld.me for documentation. See the [releases](https://github.com/afeld/jsonp/releases) page for the [client library](client/jsonp.js) changelog.

## Development

Code is written in a combination of JavaScript and TypeScript. The app is written to be deployed to a [CloudFlare Worker](https://developers.cloudflare.com/workers/) using [Terraform](https://www.terraform.io/), but can be run locally by doing the following:

1. Install NodeJS >= 7.6.0.
1. Install the dependencies.

```sh
npm install
```

1. Run the server.

```sh
npm start
```

See [CONTRIBUTING](CONTRIBUTING.md) for more info.

## Deployment

1. Install NodeJS >= 7.6.0 and [Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html).
1. Install the dependencies.

```sh
npm install
```

1. Set up CloudFlare.

1. [Sign up for CloudFlare](https://www.cloudflare.com/), and ensure you have a domain pointed there for DNS.
1. Get a CloudFlare API key.
1. Visit the [API Tokens](https://dash.cloudflare.com/profile/api-tokens) page.
1. Click `Create Token`.
1. `Use template` for `Edit Cloudflare Workers`.
1. Add permissions for `DNS` and `Zone`.
1. Go into the [`terraform/`](terraform) directory.

```sh
cd terraform
```

1. Create a `terraform/terraform.tfvars` file.

```hcl
cloudflare_account_id = "..."
cloudflare_token = "..."
```

1. [Create a Terraform Cloud account.](https://app.terraform.io/signup)
1. Set up Terraform.

```sh
terraform init
```

1. Deploy the environment.

```sh
cd ..
npm run deploy
```

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

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

## See also

- https://github.com/jpillora/xdomain
- https://github.com/mapbox/corslite
- http://enable-cors.org