// Cloudflare Workers configuration for https://ytgenerator.stream. // // This is the only deployment file in the repo: Workers Builds (connected to // this GitHub repository in the Cloudflare dashboard) runs `npx wrangler // deploy` on every push to `main`, and `build.command` below produces `dist/`. // There is no GitHub Actions deploy workflow. See docs/HOSTING.md. { "$schema": "node_modules/wrangler/config-schema.json", // Must match the Worker the repository is connected to in the dashboard. "name": "youtube-generator", // The Turnstile gate + security headers in front of the static build. "main": "worker/index.ts", // Keep at or below the date the pinned wrangler's local runtime supports. "compatibility_date": "2026-09-25", // Serve the site only on the custom domain. `wrangler deploy` detaches any // custom domain that is not listed here, so this entry is load-bearing. "workers_dev": false, "preview_urls": true, "routes": [{ "pattern": "ytgenerator.stream", "custom_domain": true }], "build": { "command": "npm run build" }, "assets": { "directory": "./dist", "binding": "ASSETS", // NOT the SPA fallback: any path excluded from the Worker below would then // get index.html without passing the gate. The Worker serves the app shell // itself for gated routes; misses on public paths get dist/404.html. "not_found_handling": "404-page", // Everything goes through the Worker first, except content-hashed build // output and the public files crawlers, browsers and the manifest fetch // without cookies. Negative patterns win. "run_worker_first": [ "/*", "!/assets/*", "!/icons/*", "!/.well-known/*", "!/favicon.svg", "!/favicon.ico", "!/apple-touch-icon.png", "!/og-image.png", "!/manifest.webmanifest", "!/robots.txt", "!/sitemap.xml", "!/theme-init.js", "!/licenses/*", "!/404.html" ] }, // Per-client rate limits (Workers Rate Limiting API): the second layer, // behind the zone's WAF rate limiting rule — see docs/HOSTING.md. Counted // per Cloudflare location, approximately, by IPv4 address or IPv6 /64. // Over the limit → 429 with Retry-After. `period` may be 10 or 60 and must // equal RATE_LIMIT_PERIOD_SECONDS in worker/env.ts; `namespace_id` is an // integer (as a string) unique within the Cloudflare account. "ratelimits": [ // Every request the Worker handles: the gate, the app shell, legal pages. { "name": "RATE_LIMIT", "namespace_id": "1001", "simple": { "limit": 120, "period": 60 } }, // POST /__gate/verify on top of that — each one costs a siteverify call. { "name": "VERIFY_RATE_LIMIT", "namespace_id": "1002", "simple": { "limit": 10, "period": 60 } } ], "vars": { // Public by design — the widget embeds it in the page. The matching // secret is the dashboard Secret TURNSTILE_SECRET (never committed). "TURNSTILE_SITE_KEY": "0x4AAAAAAFKFAMUx9rQ5H6bQ", // How long a passed check lasts before the gate shows again. "GATE_TTL_SECONDS": "86400" }, "observability": { "enabled": true } }