LinkBuddy URL Shortener
🔐 Step 1: Create a Cloudflare API Token
Go to https://dash.cloudflare.com/profile/api-tokens
Click “Create Token”
Choose “Use template” → “Edit Cloudflare Workers”
In the Zone Resources section:
Change from “All Zones” to “Include specific”
Select the domain you’re using for your Worker (or your account if not using a zone-bound domain)
Scroll to the bottom and click Continue to summary → Create Token
Copy the token immediately (you won't see it again)
🛠️ Step 2A: Store It as a GitHub Secret (for CI/CD)
In your GitHub repo:
Go to Settings → Secrets and variables → Actions
Click “New repository secret”
Name it:
CLOUDFLARE_API_TOKEN
Paste your token in the value field and save
Now your GitHub Action (like deploy.yml) can access it for automated deployments!
🛠️ Step 2B: Or Set It Locally (for wrangler deploy)
Run this in your terminal:
export CLOUDFLARE_API_TOKEN=
Then you can deploy manually:
wrangler deploy
🧠 Key Terms in Cloudflare:
Namespace name: This is the human-readable name you gave when creating the KV namespace, like linkbuddy-analytics.
Binding name: This is the name your Worker code uses to access that namespace, like ANALYTICS or URL_KV.
Namespace ID: This is the unique identifier for the namespace, e.g., 739a43fa87ae4529bd86f351acfd8576.
curl -X POST http://localhost:8787/publish -H "Content-Type: application/json" -d '[{"slug": "gh", "url": "https://github.com/unicorn_eth"}]'