// cotton-site — one Worker: static pages (built by src/site/build.ts from // apps.json: /, /about, /privacy, /terms, /support, one per app, the 404) from the asset layer, plus the legacy-host 308 and the Mac routes // (`/mac/appcast.xml`, `/mac/download/…`, `/mac/runner/…`) in // src/worker/index.ts. It holds no database: the release-notice intake and its // D1 binding are gone (8 Nov 2026); the D1 database itself is left in place. // Deploy: pnpm --filter @cottondb/site run deploy — the `run` is required, // because `deploy` is a pnpm builtin that shadows the package script. // Every `wrangler deploy` builds first with `build:live`, which refuses a page // still holding an owner's blank (src/pages/blanks.ts); `--env dev` builds the // preview, blanks marked. { "$schema": "node_modules/wrangler/config-schema.json", "name": "cotton-site", "main": "src/worker/index.ts", "compatibility_date": "2026-07-01", // The live build: it stops the deploy while any page holds a blank. "build": { "command": "pnpm run build:live" }, // The workers.dev URL is the review surface. "workers_dev": true, "assets": { "directory": "./dist", "binding": "ASSETS", // A real 404: a path with no file behind it answers `404.html` at 404 // status from the asset layer itself. "not_found_handling": "404-page", // ── THIS FLAG IS LOAD-BEARING. WITHOUT IT THE WORKER NEVER RUNS. ──────── // // With `not_found_handling` set, nothing fails to match in the asset // layer: every unmatched path is answered `404.html` there and the Worker // is never invoked. The Worker still has two jobs the asset layer cannot // do: the Mac routes (`/mac/appcast.xml` and `/mac/download/…` forwarded // to the serving Mac, `/mac/runner/…` out of R2; the Mac app updates // through them), and the legacy-host 308, which must see EVERY request on // cotton.tinmen.ai and www.cottondb.com — a pattern list cannot be // host-conditional (with one, `cotton.tinmen.ai/` was answered 200 by the // asset layer and never redirected, caught live 2026-08-16). So `true`; // a page loses nothing, the Worker's fallback is `env.ASSETS.fetch`. "run_worker_first": true }, "vars": { // Where the legacy hosts redirect to. "PUBLIC_ORIGIN": "https://cottondb.com", // The serving Mac, through the relay: /mac/appcast.xml and // /mac/download/ are answered by Cotton off the release records // (crates/cotton-server/src/routes/mac_feed.rs). "MAC_FEED_ORIGIN": "https://mukesh.relay.cottondb.com" }, // cottondb.com is THE domain, but this Worker does not hold it: a hostname // has one Worker, and since 27 Oct 2026 the business Worker (apps/business, // the open door) does. It hands this Worker every request on cottondb.com // that is not the door's own (/v1/*, /mcp, /health, /internal/*, or anything // carrying Authorization) over its service binding SITE, the request // unchanged. Listing cottondb.com here would take the domain back on the // next deploy. cotton.tinmen.ai and www stay attached so old links resolve — // the Worker answers them with a 308 to cottondb.com. "routes": [ { "pattern": "www.cottondb.com", "custom_domain": true }, { "pattern": "cotton.tinmen.ai", "custom_domain": true } ], // The darwin CI runner binary (`/mac/runner/…`, src/shared/macRunner.ts), // written only by `publish-mac-runner.yml`. "r2_buckets": [ { "binding": "MAC_RELEASES", "bucket_name": "cotton-mac-releases" } ], "observability": { "enabled": true }, // Named environments do NOT inherit top-level `vars`/`r2_buckets` — every // key is redeclared on purpose (top level serves PRODUCTION, `--env dev` // serves local work: `pnpm --filter @cottondb/site dev:worker`). "env": { // The private preview: the Worker cotton-site-preview, on its workers.dev address only, with no route and no // custom domain (routes are inherited, so they are emptied here on purpose), built as a preview. Deploy (the // coordinator only): pnpm --filter @cottondb/site exec wrangler deploy --env preview "preview": { "build": { "command": "pnpm run build" }, "workers_dev": true, "routes": [], "vars": { "PUBLIC_ORIGIN": "https://cottondb.com", "MAC_FEED_ORIGIN": "https://mukesh.relay.cottondb.com" }, "r2_buckets": [ { "binding": "MAC_RELEASES", "bucket_name": "cotton-mac-releases" } ] }, "dev": { "build": { "command": "pnpm run build" }, "vars": { "PUBLIC_ORIGIN": "http://localhost:8787", "MAC_FEED_ORIGIN": "https://mukesh.relay.cottondb.com" }, "r2_buckets": [ { "binding": "MAC_RELEASES", "bucket_name": "cotton-mac-releases" } ] } } }