Measured on production after the 4.5.0 deploy: with a new connection per request, 1,000 requests in 53 s got no 429 from RL_SITE (120/60 s); over one keep-alive connection, 429 after ~93. The ratelimits binding counts per machine of a data centre and syncs late, so the zone's WAF rule is the limit that holds against floods. Verified once the owner set the rule (300/10 s): 800 requests in 4.9 s gave 111 x 200, 201 x Worker 429 and 488 x WAF 1015, with the site answering again 10 s later. Runbook test commands, code comments, CLAUDE.md gotcha 43, the 4.5.0 changelog entry. [skip-discuss] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
7.7 KiB
JSON
147 lines
7.7 KiB
JSON
// Cloudflare Workers Builds config for https://freeitchgames.win
|
||
// Dashboard: Worker "free-games-itchio-list" → Settings → Build:
|
||
// Root directory: webapp · Build command: npm run build · Deploy command: npx wrangler deploy
|
||
// Custom Domains (freeitchgames.win, www) are attached in the dashboard and are
|
||
// intentionally not declared here yet, so a deploy never touches them.
|
||
//
|
||
// Secrets are NOT in this file: `npx wrangler secret put <NAME>` (and
|
||
// webapp/.dev.vars for `wrangler dev`) — GH_APP_PRIVATE_KEY, ADMIN_EMAILS,
|
||
// TURNSTILE_SECRET, GATE_SECRET, GATE_BOT_TOKEN. Until a feature's settings are
|
||
// filled in, its routes answer 503 and the verification gate stays off (see
|
||
// worker/env.ts, worker/gate.ts); the public site works without any of them.
|
||
// After editing this file run `npm run cf:types`.
|
||
{
|
||
"$schema": "./node_modules/wrangler/config-schema.json",
|
||
// MUST match the Worker name in the dashboard or Workers Builds fails.
|
||
"name": "free-games-itchio-list",
|
||
"main": "./worker/index.ts",
|
||
"compatibility_date": "2026-09-15",
|
||
// workers.dev / preview URLs would bypass Cloudflare Access (the admin).
|
||
"workers_dev": false,
|
||
"preview_urls": false,
|
||
"assets": {
|
||
// Vite build output (app + admin + bundled catalog under /data). Never a source dir.
|
||
"directory": "./dist",
|
||
"binding": "ASSETS",
|
||
// Misses go to the Worker, not to an asset-layer SPA fallback: that would
|
||
// answer a stale hashed chunk (/assets/x-OLD.js after a deploy) with
|
||
// index.html + the year-long immutable cache of /assets/*. The Worker
|
||
// returns real 404s for files and serves the app shell for routes
|
||
// (worker/spa.ts).
|
||
"not_found_handling": "none",
|
||
"html_handling": "auto-trailing-slash",
|
||
// Existing assets never invoke the Worker (free, cached); these paths always
|
||
// do — "/" (served from dist/index.html otherwise) so the verification gate
|
||
// sees it like every other app page, /admin so its shell is only ever served
|
||
// after the Access JWT check, and the readable catalog JSON, which only
|
||
// apps 4.0–4.1.1 still get (worker/legacy-data.ts). Listed one by one on
|
||
// purpose: a negative pattern ("!/data/pack/*") would send a missing pack to
|
||
// the asset layer, whose 404 carries the year-long immutable header.
|
||
"run_worker_first": [
|
||
"/",
|
||
"/img/*",
|
||
"/api/*",
|
||
"/admin",
|
||
"/admin/*",
|
||
"/data/index.json",
|
||
"/data/count_history.json",
|
||
"/data/deleted_games.json",
|
||
"/data/urls.json",
|
||
"/data/game_info_*"
|
||
]
|
||
},
|
||
// Resized cover images, written once per image + width by worker/img.ts.
|
||
"r2_buckets": [{ "binding": "THUMBS", "bucket_name": "freeitchgames-thumbs" }],
|
||
// Review queue (worker/migrations). The database was created with
|
||
// `npx wrangler d1 create freeitchgames` (APAC); its id is not a secret.
|
||
// Migrations are applied by hand, never by the build:
|
||
// npx wrangler d1 migrations apply freeitchgames --remote
|
||
"d1_databases": [
|
||
{
|
||
"binding": "DB",
|
||
"database_name": "freeitchgames",
|
||
"database_id": "5a2417f2-cfe6-4a42-ad9c-2f8bb7094a61",
|
||
"migrations_dir": "./worker/migrations"
|
||
}
|
||
],
|
||
// Per-IP limits (an IPv6 client by its /64), counted per machine of each
|
||
// Cloudflare data centre (approximate: they hold for a client on one
|
||
// connection, not for one that opens a new connection per request); over a
|
||
// limit the Worker answers 429 + Retry-After (worker/ratelimit.ts).
|
||
// Every request that runs the Worker counts against one of RL_SITE (app
|
||
// pages, the public /api, the readable /data JSON, misses), RL_IMG (covers:
|
||
// a Games page shows up to 100) or RL_ADMIN (/admin + /api/admin, behind
|
||
// Access); verified bots don't count. POSTs to the Suggest form and the
|
||
// verification gate also count against their own, stricter RL_SUGGEST /
|
||
// RL_GATE (the gate's is higher: carrier-grade NAT puts many phones behind
|
||
// one address). Static assets never run the Worker: the zone's WAF
|
||
// rate-limiting rule is the first layer for everything (docs/operations.md
|
||
// §1 step 15). Keep "period" 60 (the Retry-After). A namespace_id is
|
||
// account-wide: two bindings with the same one share their counters, even in
|
||
// different Workers. Other Workers on this account use the low numbers
|
||
// (1001–1006…), so this one keeps to 88xx (staging 89xx; before 4.5.0 it had
|
||
// 1001–1003 / 2001–2003, shared with them).
|
||
"ratelimits": [
|
||
{ "name": "RL_SUGGEST", "namespace_id": "8801", "simple": { "limit": 5, "period": 60 } },
|
||
{ "name": "RL_GATE", "namespace_id": "8803", "simple": { "limit": 20, "period": 60 } },
|
||
{ "name": "RL_SITE", "namespace_id": "8804", "simple": { "limit": 120, "period": 60 } },
|
||
{ "name": "RL_IMG", "namespace_id": "8805", "simple": { "limit": 600, "period": 60 } },
|
||
{ "name": "RL_ADMIN", "namespace_id": "8806", "simple": { "limit": 300, "period": 60 } }
|
||
],
|
||
// RSS discovery (one feed per run) + queue bookkeeping, worker/index.ts scheduled().
|
||
"triggers": { "crons": ["23 */4 * * *"] },
|
||
"vars": {
|
||
"SITE_ORIGIN": "https://freeitchgames.win",
|
||
"GITHUB_REPO": "poli0981/free-games-itchio-list",
|
||
"BOT_UA": "FreeItchGamesBot/4.0 (+https://freeitchgames.win/about)",
|
||
// None of these are secret. Keep them here, not only in the dashboard: every
|
||
// deploy replaces the Worker's plain-text variables with this file's values.
|
||
"GH_APP_ID": "4988105",
|
||
"GH_APP_INSTALLATION_ID": "162777505",
|
||
"ACCESS_TEAM_DOMAIN": "https://polished-hall-48fd.cloudflareaccess.com", // no trailing slash
|
||
"ACCESS_AUD_ADMIN": "fc4d79904ffb90f7405cabb0135e15940c7bad48ba344309adc085d71622f482", // "Admin" Access app
|
||
"TURNSTILE_SITEKEY": "0x4AAAAAAE7oBxYiQZ_lVEBW",
|
||
// Verification gate (worker/gate.ts). "on" still needs the GATE_SECRET and
|
||
// GATE_BOT_TOKEN secrets; the instant off switch is deleting GATE_SECRET.
|
||
"BOT_GATE": "on",
|
||
"BOT_GATE_TTL_HOURS": "48"
|
||
},
|
||
"observability": { "enabled": true, "head_sampling_rate": 0.1 },
|
||
"upload_source_maps": false,
|
||
|
||
"env": {
|
||
// Pre-release checks: Worker "free-games-itchio-list-staging", deployed by hand
|
||
// from any branch with `npx wrangler deploy --env staging`, whole host behind
|
||
// Access. workers_dev / preview_urls (false) and triggers are inherited from
|
||
// the top level; bindings and vars are not, so every one is repeated here.
|
||
"staging": {
|
||
"routes": [{ "pattern": "staging.freeitchgames.win", "custom_domain": true }],
|
||
"r2_buckets": [{ "binding": "THUMBS", "bucket_name": "freeitchgames-thumbs-staging" }],
|
||
"d1_databases": [
|
||
{ "binding": "DB", "database_name": "freeitchgames-staging", "migrations_dir": "./worker/migrations" }
|
||
],
|
||
"ratelimits": [
|
||
{ "name": "RL_SUGGEST", "namespace_id": "8901", "simple": { "limit": 5, "period": 60 } },
|
||
{ "name": "RL_GATE", "namespace_id": "8903", "simple": { "limit": 20, "period": 60 } },
|
||
{ "name": "RL_SITE", "namespace_id": "8904", "simple": { "limit": 120, "period": 60 } },
|
||
{ "name": "RL_IMG", "namespace_id": "8905", "simple": { "limit": 600, "period": 60 } },
|
||
{ "name": "RL_ADMIN", "namespace_id": "8906", "simple": { "limit": 300, "period": 60 } }
|
||
],
|
||
// No RSS polling from staging: production is the only itch.io client.
|
||
"triggers": { "crons": [] },
|
||
"vars": {
|
||
"SITE_ORIGIN": "https://staging.freeitchgames.win",
|
||
"GITHUB_REPO": "poli0981/free-games-itchio-list",
|
||
"BOT_UA": "FreeItchGamesBot/4.0 (+https://freeitchgames.win/about)",
|
||
"GH_APP_ID": "",
|
||
"GH_APP_INSTALLATION_ID": "",
|
||
"ACCESS_TEAM_DOMAIN": "",
|
||
"ACCESS_AUD_ADMIN": "",
|
||
"TURNSTILE_SITEKEY": "",
|
||
"BOT_GATE": "off",
|
||
"BOT_GATE_TTL_HOURS": "48"
|
||
}
|
||
}
|
||
}
|
||
}
|