https://github.com/unlock-protocol/cloudflare-worker
A cloudflare worker to add a lock to any website!
https://github.com/unlock-protocol/cloudflare-worker
Last synced: about 1 year ago
JSON representation
A cloudflare worker to add a lock to any website!
- Host: GitHub
- URL: https://github.com/unlock-protocol/cloudflare-worker
- Owner: unlock-protocol
- Created: 2020-03-30T18:59:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T06:36:22.000Z (over 4 years ago)
- Last Synced: 2025-04-08T21:41:25.077Z (about 1 year ago)
- Language: JavaScript
- Size: 365 KB
- Stars: 24
- Watchers: 4
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 👷 A Cloudflare Worker to lock 🔓 a webpage
A Cloudflare woekr which lets website owners easily deploy an access control layer for monetization with [Unlock](https://unlock-protocol.com).
You can try it out by going to https://token-gated.com/ which is token gated an requires ownership of a membership (it is using the Rinkeby test network, so you don't need to spend real money).
## How to
### Clone the repo:
```bash
git clone git@github.com:unlock-protocol/cloudflare-worker.git
```
### Configure worker
Update its `.src/config.js` file to match your needs. Importantly, you need to keep the `pessimistic` mode to be `true` .
### Install dependencies
```bash
yarn
```
### Push to cloudflare
```bash
yarn wrangler publish
```
(You will likely be prompted to login to CloudFlare first)
### Configure website
Now that the worker is deployed, you need to link it to your CloudFlare sites. Your mileage may vary but here is howe we did it for https://token-gated.com. From the Cloudflare Dashboard, select your website, in the left column, click on "Workers". Click the `Add Route` button. Enter the route(s) you want to "token-gate". In the `Service` select, pick the `unlock-cloudflare-worker` and select the environment of choice. Hit `Save`. You're all set!

## Contributing
You are encouraged to open pull-requests and help us improve this worker!