mirror of
https://github.com/peterlodri-sec/tiny.vaked.dev.git
synced 2026-11-22 00:10:06 +01:00
Self-hosted URL shortener on Cloudflare (Worker + KV)
- JavaScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| package.json | ||
| README.md | ||
| wrangler.toml | ||
tiny.vaked.dev
A self-hosted URL shortener on Cloudflare (Worker + KV). Private: creating links requires a Bearer token; anyone can follow a short link.
GET /— themed landing page with a create form (paste your token; kept inlocalStorage).GET /:slug— 302 redirect to the target (increments a click counter).POST /api/shorten— create a link. RequiresAuthorization: Bearer <SHORTEN_TOKEN>. Body:{ "url": "https://…", "slug": "optional-custom" }→{ slug, url, short }.GET /health—{ ok: true }.
Deploy
npm install
npx wrangler kv namespace create LINKS # put the id in wrangler.toml
npx wrangler deploy # custom domain: tiny.vaked.dev
echo -n '<your-secret>' | npx wrangler secret put SHORTEN_TOKEN
# (if npx trips the nvm shim, use: node node_modules/wrangler/bin/wrangler.js secret bulk sec.json)
Create a link
curl -X POST https://tiny.vaked.dev/api/shorten \
-H "authorization: Bearer $SHORTEN_TOKEN" -H "content-type: application/json" \
-d '{"url":"https://example.com/long","slug":"demo"}'
Note: the vaked.dev zone has a Cloudflare bot rule (error 1010) that blocks
default script User-Agents — send a normal User-Agent header from scripts. Browsers
are unaffected.
Stack
Cloudflare Worker (src/index.js, module syntax) + Workers KV (LINKS). No build step.
pocoo-themed UI. MIT.