Upvoteworkers
Cloudflare Workers Upvote Backend Setup
1. Create Cloudflare Account
- Go to https://dash.cloudflare.com/sign-up
- Sign up with email and verify
- Skip any domain setup prompts
2. Create KV Namespaces
- In Cloudflare dashboard, click Workers & Pages in left sidebar
- Click KV tab
- Click Create namespace
- Name it
upvote-count→ Click Add - Click Create namespace again
- Name it
upvote-record→ Click Add
You should now see both namespaces listed.
3. Create Worker
- Go back to Workers & Pages
- Click Create button → Create Worker
- Name it
upvote-api(or whatever you want) - Click Deploy
- Click Edit code
4. Add Worker Code
- Delete all the default code in the editor
- Copy the worker code from: ==[LINK TO GITHUB SCRIPT]==
- Paste it into the editor
- Click Deploy (top right)
5. Generate Salt Secret
Open your terminal and run:
openssl rand -base64 32Copy the output (a long random string like xK9mP2vL8nQ4tR6wY1zA5bC3dE7fG0hI2jK4lM6nO8pQ=)
You could also use an online tool like this one, but it’s probably not a good idea.
6. Configure Environment Variables
- In your worker, click Settings → Variables
- Click Add variable
Variable 1: SALT_SECRET
- Type: Select “Secret” (shows a lock icon)
- Variable name:
SALT_SECRET - Value: Paste your generated salt
- Click Save
Variable 2: ALLOWED_ORIGINS
- Click Add variable
- Type: “Text”
- Variable name:
ALLOWED_ORIGINS - Value:
https://yourdomain.com,https://www.yourdomain.com- Replace with YOUR actual domain(s)
- Comma-separated, no spaces
- Must include
https:// - No trailing slash
- Click Save
7. Bind KV Namespaces
Still in Settings → Variables, scroll to KV Namespace Bindings:
Binding 1:
- Click Add binding
- Variable name:
UPVOTE_COUNT(must be exact) - KV namespace: Select
upvote-count - Click Save
Binding 2:
- Click Add binding
- Variable name:
UPVOTE_RECORD(must be exact) - KV namespace: Select
upvote-record - Click Save
8. Set your upvote API URL in Blot
- Go to Settings → Triggers
- Under Routes, you’ll see a
*.workers.devURL - Copy this URL (e.g.,
https://upvote-api.your-account.workers.dev) - Set
upvote_urlinpackage.jsonto this URL, whether via theblot.imfrontend or your sync service.
9. Testing
Browser Test (from your allowed domain):
Open browser console on your website and run:
fetch('https://upvote-api.your-account.workers.dev/count?post=test-123')
.then(r => r.json())
.then(console.log);Should return: {code: 0, msg: "success", data: {post: "test-123", count: 0, hasUpvoted: false}}
Test upvote:
fetch('https://upvote-api.your-account.workers.dev/upvote', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({postId: 'test-123', diff: 1})
}).then(r => r.json()).then(console.log);Should return: {code: 0, msg: "success", data: {count: 1}}
Test again:
fetch('https://upvote-api.your-account.workers.dev/count?post=test-123')
.then(r => r.json())
.then(console.log);Should return: {code: 0, msg: "success", data: {post: "test-123", count: 1, hasUpvoted: true}}
Common Issues
“SALT_SECRET is not defined” - Go back to Settings → Variables and make sure you added it as a Secret (not Text) - Check spelling is exactly SALT_SECRET
“CORS error” on my own site - Check ALLOWED_ORIGINS exactly matches your domain - Must include https:// - No trailing slash: https://example.com NOT https://example.com/ - Check www vs non-www (add both if needed)
“UPVOTE_COUNT is not defined” - Go to Settings → Variables → KV Namespace Bindings - Make sure variable names are exactly UPVOTE_COUNT and UPVOTE_RECORD - Make sure they’re bound to the correct namespaces
Worker returns 404 - Make sure you deployed the code (clicked Deploy button) - Try the worker URL directly in browser - should return JSON
Free Tier Limits (November 2025)
- 100,000 requests/day
- 1,000 KV writes/day
- 100,000 KV reads/day
- 1 GB KV storage
For a personal blog, you’ll probably never hit these limits.