Routes and custom domains: how a Worker gets a hostname
Routes and custom domains
What it is
A Worker script does nothing useful on its own until traffic is sent to it. Cloudflare has two common ways to attach a hostname in your zone to a Worker: a route, and a custom domain.
A route is a pattern plus a zone. The pattern is usually a hostname and a path, such as cloudflare.kosan.xyz/* . When a request arrives at Cloudflare for a matching name and path, Cloudflare runs that Worker. Routes do not invent DNS. The hostname still needs to resolve through Cloudflare (proxied) so the request reaches the edge.
A Worker custom domain is the shorter path for an exact hostname. You attach the name (for example cloudflare.kosan.xyz) to the Worker. Cloudflare publishes the DNS row for that name in the zone and proxies it for you. In wrangler.toml this often appears as a [[routes]] entry with custom_domain = true on the bare hostname, next to a separate pattern for paths.
In practice many deployments use both: the custom-domain style entry for the exact name, and a /* pattern so every path on that hostname hits the same Worker. They are related, but they are not the same setting.
Why it matters
If you host a site, a small app, or an agent harness on a Worker, the hostname only works when the script is bound to that name. Deploying the script without a route or custom domain leaves the code on Cloudflare but nothing in your zone calling it (except the optional workers.dev URL).
Wrong patterns are a common failure mode. A route for one subdomain does not cover another. cloudflare.kosan.xyz/* does not match the apex kosan.xyz, and it does not match a different subdomain in the same zone. Editing the wrong Worker’s routes can steal traffic from a live hostname.
For day-to-day GP and AI tools on kosan.xyz, the stable pattern is one Worker, one hostname, routes limited to that name. Knowing route versus custom domain lets you read wrangler.toml and the dashboard without guessing why a name works.
On your account
This tutor is the Worker named cloudflare-tutor. Its wrangler.toml binds only cloudflare.kosan.xyz. There is a [[routes]] pattern cloudflare.kosan.xyz/* with zone_name = "kosan.xyz", and a second [[routes]] entry for the bare hostname cloudflare.kosan.xyz with the same zone and custom_domain = true. Redeploying this Worker republishes that script and those two triggers only.
Other kosan.xyz Workers you run follow the same idea: attach the Worker to its own hostname with a route and/or custom domain in that zone. The pattern stays scoped to that name so one deploy does not rewrite traffic for a different app.
Leave production routes and DNS alone while you learn this. Do not open or change Single Redirect rules, and do not edit routes on other Workers. Today is only about recognising how this tutor’s hostname is wired.
Do this yourself
These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.
- Open the Cloudflare dashboard, go to Workers & Pages, open the Worker named cloudflare-tutor, then Triggers (or Settings → Triggers / Domains & Routes, depending on the UI). Confirm you see cloudflare.kosan.xyz as a custom domain and/or a route pattern for cloudflare.kosan.xyz/* in the kosan.xyz zone. Read only. Do not add, edit, or delete any route or domain.
- Still looking only, open Workers & Pages and pick one other Worker you recognise on kosan.xyz. Open its Triggers the same way and note whether it uses a custom domain, a route pattern, or both — then close without saving. Do not change routes, DNS, Single Redirect rules, or Workers named ainews or aiweekly. Optional throwaway only: create a new Worker named only tutor-routes-lesson, do not attach any domain or route, open Triggers once to see the empty list, then delete that same Worker.