Follow these steps to install dependencies, create the required KV storage, and configure secrets for the Cloudflare Worker.
1. Install Dependencies
cd worker
npm install
2. Create KV Namespace
Create a KV namespace named VOTES for production and preview environments:
npx wrangler kv namespace create VOTES
npx wrangler kv namespace create VOTES --preview
Copy the resulting IDs into your wrangler.toml file:
[[kv_namespaces]]
binding = "VOTES"
id = "<production-id>"
preview_id = "<preview-id>"
3. Configure Secrets
Store your GitHub OAuth credentials as Cloudflare Worker secrets:
npx wrangler secret put GH_CLIENT_ID
npx wrangler secret put GH_CLIENT_SECRET
4. Configure CORS
Update the ALLOWED_ORIGIN variable in wrangler.toml to match your deployed site URL to ensure correct CORS behavior.
cd worker
npm install
npx wrangler kv namespace create VOTES
npx wrangler kv namespace create VOTES --preview
npx wrangler secret put GH_CLIENT_ID
npx wrangler secret put GH_CLIENT_SECRET