Measured on production after v4.5.1 deployed (2026-10-27, SIN): over one keep-alive connection each budget held exactly - /api/no-such-route 121 x 404 then 429 with Retry-After, no-store and CORS; /api/human-check 19 then 429 - while requests on fresh connections, which Cloudflare spreads over many servers, were never refused (175 human checks in 70 s against a budget of 20). A probe Worker in a remote preview confirmed the binding itself enforces (limit 5: 6 allowed, then refused). So the layer stops browsers and connection-reusing scripts; a client that reconnects for every request is the WAF rule's, which counted exactly (250). The docs, CLAUDE.md, the module comment, wrangler.jsonc and the unpublished v4.5.1 entry said "per location, approximate"; they now say what was measured. The section 3b check used xargs (fresh connections) and would have shown no 429 - it now sends everything over one connection. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
196 lines
9.8 KiB
JSON
196 lines
9.8 KiB
JSON
// The ONLY deployment config for this project.
|
|
//
|
|
// Cloudflare Workers Builds (dashboard -> Worker -> Settings -> Build) is
|
|
// pointed at this repo with root directory "web", so this file, package.json
|
|
// and the lockfile sit together and dependency auto-detection works. There is
|
|
// deliberately no deploy workflow in .github/workflows — pushing main deploys.
|
|
{
|
|
"$schema": "node_modules/wrangler/config-schema.json",
|
|
|
|
// MUST match the existing Worker that holds the free-steam-games.win
|
|
// custom domain. Deploying under any other name creates a second,
|
|
// domainless Worker and leaves the live site on the old build.
|
|
"name": "free-steam-games-list",
|
|
"main": "./worker/index.ts",
|
|
"compatibility_date": "2026-09-10",
|
|
|
|
// Empty on purpose. The Worker uses only fetch, Web Crypto and D1, so
|
|
// nodejs_compat would add cold-start cost for nothing.
|
|
"compatibility_flags": [],
|
|
|
|
// No *.workers.dev hostname. A zone-scoped Cloudflare Access policy does not
|
|
// cover workers.dev, so leaving it enabled would expose /admin — and the
|
|
// repo-write credential behind it — on an unprotected hostname.
|
|
"workers_dev": false,
|
|
|
|
"assets": {
|
|
// Vite's build output. NOT "." — pointing this at the source directory
|
|
// once served an unbuilt index.html (referencing /src/main.tsx) along with
|
|
// the whole source tree. The admin app is NOT in here: it is embedded in
|
|
// the Worker script (admin/, worker/generated/admin-bundle.ts).
|
|
"directory": "./dist",
|
|
|
|
// Lets worker/index.ts fall through via env.ASSETS.fetch(request).
|
|
"binding": "ASSETS",
|
|
|
|
// Any path matching no file returns index.html with HTTP 200 - the
|
|
// PRERENDERED dashboard, which src/lib/fallback-route.ts corrects for the
|
|
// routes that can arrive this way. Replaces the GitHub Pages 404.html trick.
|
|
//
|
|
// Consequence worth remembering: a request for a DELETED hashed chunk also
|
|
// gets index.html at 200, so the browser rejects it on MIME type rather
|
|
// than status. src/lib/chunk-error.ts's isChunkLoadError matches that
|
|
// message.
|
|
"not_found_handling": "single-page-application",
|
|
|
|
// Worker code runs ONLY for these prefixes; everything else is served
|
|
// straight from the asset server, unbilled, never invoking the Worker.
|
|
// /img/* must be listed or image requests fall through to the SPA handler
|
|
// and come back as index.html with Content-Type: text/html. /admin must be
|
|
// listed or the SPA fallback serves the public shell where Access is
|
|
// expected, and it covers the admin app's own /admin/assets/*. /_app/* is
|
|
// deliberately NOT listed — routing the site's hashed bundles through the
|
|
// Worker would bill every JS/CSS request.
|
|
"run_worker_first": ["/api/*", "/img/*", "/admin", "/admin/*"]
|
|
},
|
|
|
|
"observability": {
|
|
"enabled": true,
|
|
"head_sampling_rate": 1
|
|
},
|
|
|
|
// Admin-only state: the new-games queue, decisions, commit jobs and the
|
|
// audit log. (Not "edit drafts" - there is no such table.) Game data
|
|
// stays canonical in Git — D1 never holds game records.
|
|
"d1_databases": [
|
|
{
|
|
"binding": "DB",
|
|
"database_name": "f2p-admin",
|
|
"database_id": "31b570e2-1863-4ccd-a019-dee4eadc3921",
|
|
// Without this wrangler looks in web/migrations and reports "no
|
|
// migrations present" while the files sit here.
|
|
"migrations_dir": "./worker/migrations"
|
|
}
|
|
],
|
|
|
|
// AVIF copies of Steam header art, minted by the cron (worker/lib/img-mint.ts)
|
|
// and read by /img/* (worker/routes/img.ts). Created 2026-10-02 with
|
|
// `wrangler r2 bucket create f2p-media`; it must exist before a deploy that
|
|
// binds it, or the deploy fails (code 10085) and the old Worker stays live.
|
|
// No public access: no r2.dev URL, no custom domain - the Worker is the only
|
|
// reader. An R2 bucket has no id; the name is the whole binding.
|
|
"r2_buckets": [
|
|
{
|
|
"binding": "MEDIA",
|
|
"bucket_name": "f2p-media"
|
|
}
|
|
],
|
|
|
|
// Cloudflare Images, used only from the cron to encode AVIF. It takes the
|
|
// bytes directly, so the zone's Transformations "Sources" list is not
|
|
// involved - keep that list empty ("This zone only"): adding Steam's hosts
|
|
// would let anyone spend this account's quota through /cdn-cgi/image/.
|
|
"images": {
|
|
"binding": "IMAGES"
|
|
},
|
|
|
|
// Per-IP request limits, the Worker's half of rate limiting
|
|
// (worker/lib/rate-limit.ts). The zone's WAF rate-limiting rule is the
|
|
// first layer and refuses a burst before this Worker runs at all
|
|
// (docs/SECURITY_SETUP.md section 3); the Free plan fixes it at 10 seconds,
|
|
// one rule. These add a 60-second window and one budget per surface, and
|
|
// still hold if that rule is edited or deleted. They see only the four
|
|
// `run_worker_first` prefixes - the prerendered pages are the WAF's alone.
|
|
//
|
|
// Counts are effectively per server (measured: a budget held exactly over
|
|
// one keep-alive connection and not at all across fresh connections), so a
|
|
// client that reconnects for every request is the WAF rule's to stop. The
|
|
// key is the client's IPv4 address or IPv6 /64. Over a limit the Worker
|
|
// answers 429 with Retry-After: 60, so every "period" stays 60
|
|
// (rate-limit.test.ts holds that). A namespace_id must be unique within the Cloudflare account:
|
|
// two bindings that share one share counters, across Workers too.
|
|
//
|
|
// RL_DATA /api/data/* a cold catalogue load is ~16 requests
|
|
// RL_IMG /img/* the apps fetch every thumbnail here
|
|
// RL_API /api/activity, /api/updates/desktop, any other public /api/*
|
|
// RL_HUMAN /api/human-check a person sends one a day
|
|
// RL_ADMIN /admin, /admin/*, /api/ingest/* (behind Access as well)
|
|
"ratelimits": [
|
|
{ "name": "RL_DATA", "namespace_id": "730001", "simple": { "limit": 240, "period": 60 } },
|
|
{ "name": "RL_IMG", "namespace_id": "730002", "simple": { "limit": 600, "period": 60 } },
|
|
{ "name": "RL_API", "namespace_id": "730003", "simple": { "limit": 120, "period": 60 } },
|
|
{ "name": "RL_HUMAN", "namespace_id": "730004", "simple": { "limit": 20, "period": 60 } },
|
|
{ "name": "RL_ADMIN", "namespace_id": "730005", "simple": { "limit": 300, "period": 60 } }
|
|
],
|
|
|
|
// Reconcile approvals against the published dataset. Every 15 minutes rather
|
|
// than hourly because the gap between approving and seeing it land is the
|
|
// one moment a reviewer is actually watching; a tick with nothing approved
|
|
// costs one indexed D1 query and returns before any fetch.
|
|
"triggers": {
|
|
"crons": ["*/15 * * * *"]
|
|
},
|
|
|
|
"vars": {
|
|
"SITE_ORIGIN": "https://free-steam-games.win",
|
|
|
|
// Minting AVIF into R2 (worker/lib/img-mint.ts, from the cron). Only the
|
|
// cron transforms; /img/* only reads, so this is the whole kill switch.
|
|
// Change it HERE, by a PR: there is no keep_vars, so a dashboard value
|
|
// lasts only until the next deploy.
|
|
//
|
|
// Images Paid: 5,000 unique transformations a month included, then $0.50
|
|
// per 1,000, and Cloudflare has NO spend cap - the monthly cap below is
|
|
// the only one. The budget agreed for this is $15/month; 20,000 is at most
|
|
// $7.50, and the whole catalogue (~5,600 sources x 2 widths) is ~11k once.
|
|
"IMG_TRANSFORM": "true",
|
|
"IMG_TRANSFORM_MONTHLY_CAP": "20000",
|
|
// Sources minted per 15-minute tick (each is 2 transformations and ~6
|
|
// subrequests). The first production batch of 10 was inspected on
|
|
// 2026-10-02 (it is why `d` went from q60 to q80); 40 finishes the
|
|
// backfill in about a day and a half.
|
|
"IMG_MINT_PER_TICK": "40",
|
|
|
|
// Days audit_log and commit_jobs rows are kept (worker/lib/prune.ts, run
|
|
// once a day from the cron). docs/PRIVACY_POLICY.md states this number -
|
|
// change both together. Values under 7 are ignored as a safety floor.
|
|
"ADMIN_RETENTION_DAYS": "180",
|
|
|
|
// Countries refused by the Worker, ISO 3166-1 alpha-2, comma separated.
|
|
// "CN" is mainland China only - Hong Kong, Macau and Taiwan are HK, MO and
|
|
// TW and stay reachable.
|
|
//
|
|
// This is DEFENCE IN DEPTH, not the boundary. The Worker only ever sees
|
|
// the four `assets.run_worker_first` prefixes, so the prerendered HTML is
|
|
// not covered by it; a WAF custom rule on the zone is what actually blocks
|
|
// a country. See docs/SECURITY_SETUP.md. Empty or unset blocks nothing.
|
|
"BLOCKED_COUNTRIES": "CN,RU,AR",
|
|
|
|
// Cloudflare Access. Neither value is a secret: the team domain appears in
|
|
// the login redirect and the AUD tag identifies the application. They are
|
|
// vars so the Worker can verify tokens itself rather than trusting that a
|
|
// request reached it through the Access-protected path.
|
|
"ACCESS_TEAM_DOMAIN": "polished-hall-48fd.cloudflareaccess.com",
|
|
// AUDs are grouped BY ROUTE, not pooled into one list. verifyAccessJwt is
|
|
// called with only the group a route accepts, so the unattended discovery
|
|
// token cannot reach /admin/api/* (which holds a repository-write
|
|
// credential) and an admin session cannot reach /api/ingest/*.
|
|
//
|
|
// These are not secrets: any Access-covered path 302s to a login URL
|
|
// carrying its own AUD as the `kid=` query parameter, readable with an
|
|
// unauthenticated curl. Add a tag here whenever another Access application
|
|
// is pointed at this Worker, or every request through it is refused with
|
|
// `access: aud mismatch` in `wrangler tail`.
|
|
//
|
|
// ca93cf2c... /admin, which covers the SPA AND its API at /admin/api/*
|
|
// (email policy). ONE application on purpose: a separate one
|
|
// for the API (a15d6e93..., /api/admin/*, retired) left the
|
|
// page's fetches without a session - see ADMIN_API_PREFIX in
|
|
// shared/admin-routes.ts.
|
|
"ACCESS_AUD_ADMIN": "ca93cf2c7444c20f13b0667a3063d4ac37f702a802e712721da53abb510f9194",
|
|
|
|
// bd54655a... /api/ingest/* (Service Auth, token f2p-discovery)
|
|
"ACCESS_AUD_INGEST": "bd54655abb62f1bb72f8541177ef2406a066007a4c5ac60eb654f90f6ea88754"
|
|
}
|
|
}
|