Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/en9inerd/cors-proxy
CORS proxy based on Cloudflare Workers
https://github.com/en9inerd/cors-proxy
cloudflare cloudflare-workers cors proxy service-worker
Last synced: about 1 month ago
JSON representation
CORS proxy based on Cloudflare Workers
- Host: GitHub
- URL: https://github.com/en9inerd/cors-proxy
- Owner: en9inerd
- Created: 2023-04-15T05:25:27.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-07T20:43:24.000Z (10 months ago)
- Last Synced: 2024-03-07T21:40:58.280Z (10 months ago)
- Topics: cloudflare, cloudflare-workers, cors, proxy, service-worker
- Language: TypeScript
- Homepage:
- Size: 51.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple CORS proxy based on Cloudflare Workers
Problem statement is described in [this blog post](https://enginerd.io/2023/04/17/cors-proxy/).
## Worker deployment
1. Install Wrangler.
2. Authenticate with your Cloudflare account using `wrangler login`.
3. Update `wrangler.toml` with your event name and webhook key.
4. (Optional) Include allowed origins in the whitelist by updating the `index.ts` file. Add regular expressions for desired origins to the `whitelist` array using the format: `const whitelist: RegExp[] = [/origin1.com/, /.*\.example\.com/];`
5. Deploy the worker using `wrangler deploy`.## Usage
```typescript
fetch("https://cors-proxy.workers.dev/?apiUrl=https://api.ipify.org?format=json").then(response => {
return response.json();
}).then(data => {
console.log(data);
});
```where `https://api.ipify.org?format=json` is the URL you want to fetch and `https://cors-proxy.workers.dev` is the URL of your deployed worker.