cloudflare-worker
cloudflare-worker copied to clipboard
A cloudflare worker to add a lock to any website!
👷 A Cloudflare Worker to lock 🔓 a webpage
A Cloudflare woekr which lets website owners easily deploy an access control layer for monetization with Unlock.
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:
git clone [email protected]: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
yarn
Push to cloudflare
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!