The API refuses a wildcard host route until the zone has Cloudflare for SaaS enabled, so every deploy ended in an error. The route is a commented line in wrangler.jsonc and the last of the one-time custom domain steps.
- commit
- 52460f99737e85ed3b29b21ce41e899b29949985
- parent
- cdd249726732c33037e592d6bc975f7d9c5cd06b
- author
- Dami <dami.etoile@gmail.com>
| M | docs/ | 2 | +- |
| M | wrangler.jsonc | 6 | ++++-- |
@@ -80,7 +80,7 @@ One-time setup, in this order:
8080 | `CNAME` | `customers` | `fallback.<domain>` | on |8181 8282 `CNAME_TARGET` in `wrangler.jsonc` must match: `customers.<domain>`.83-4. **Routes.** `wrangler.jsonc` declares a `*/*` route on the zone next to the wildcard, which is what makes custom hostname traffic reach the Worker. Deploy once after the change and confirm in Workers Routes that the zone lists `*/*` for `bindws-relay`. If wrangler refuses the pattern, add it by hand on that page: route `*/*`, Worker `bindws-relay`.83+4. **Routes.** Only now can the zone take a catch-all route, which is what makes custom hostname traffic reach the Worker; before Cloudflare for SaaS is enabled the API refuses it with code 10022. Uncomment the `*/*` route in `wrangler.jsonc` and deploy, then confirm in Workers Routes that the zone lists `*/*` for `bindws-relay`. If wrangler still refuses the pattern, add it by hand on that page.8484 5. **KV namespace.** `npx wrangler kv namespace create HOSTS` and put the id in both `kv_namespaces` entries of `wrangler.jsonc` (the repo carries the bind.ws one).8585 6. **API token.** My Profile, API Tokens, Create Token, Custom token: permission **Zone, SSL and Certificates, Edit**, zone resources limited to your zone. Store it as a secret: `npx wrangler secret put CF_API_TOKEN`. `ZONE_ID` in `wrangler.jsonc` is the zone the hostnames are created in (the same id the routes use). Without the secret the console reports custom domains as not enabled and the methods answer `unsupported:`.8686 @@ -12,8 +12,10 @@
1212 // host sends it to the Worker (docs/11-hosting-bindws.md, Custom domains).1313 "routes": [1414 { "pattern": "bind.ws", "custom_domain": true },15- { "pattern": "*.bind.ws/*", "zone_id": "491aaf5e1c12976e9828199686a81733" },16- { "pattern": "*/*", "zone_id": "491aaf5e1c12976e9828199686a81733" }15+ { "pattern": "*.bind.ws/*", "zone_id": "491aaf5e1c12976e9828199686a81733" }16+ // Once Cloudflare for SaaS is enabled on the zone, add the catch-all that17+ // brings custom hostnames to the Worker; before that the API refuses it:18+ // { "pattern": "*/*", "zone_id": "491aaf5e1c12976e9828199686a81733" }1719 ],1820 "vars": {1921 // Relays live at wss://<name>.<DOMAIN>; in `wrangler dev` use <name>.localhost.