Course lesson 48 · Dev Ops & Environments
Custom Domains & Routes
The application receives its own domain, first through whole-host custom domains and then through path-based Worker routes. Separate production and stage hosts are configured, and the frontend’s socket host must be updated to match them. For short links, the final demonstrated design reserves an /r/ path prefix so requests can reach the data service without swallowing frontend routes.
Primary source: course video 48 · Supplied English subtitles · 00:15:29.
Understand the idea
- A custom domain assigns an entire hostname to a Worker, including all paths on that host.
- A route selects traffic with a pattern, allowing different Workers to serve different paths under one domain.
- URL design and routing rules are coupled: random identifiers at the root are harder to distinguish from application routes.
- Build mode and browser host configuration remain important after domain changes.
- The lesson configures HTTP-to-HTTPS redirection at the network layer before Worker execution.
What the course does
- Purchase a demonstration domain in Cloudflare and add an HTTP-to-HTTPS redirect rule.
- Configure the user application’s production custom domain and a stage subdomain.
- Correct the stage Vite build mode when deployment unexpectedly targets the production domain.
- Update frontend host variables in both Cloudflare builds and local environment files so WebSockets reconnect.
- Demonstrate separate go and go-stage subdomains for the redirect service.
- Replace that approach with /r/* route patterns and update the Hono redirect path to match.
Watch for
- The exact domain price, DNS timing, and dashboard screens are historical details of the recording.
- The instructor observes old workers.dev URLs inactive in this configuration; do not treat that as a universal rule for every custom-domain deployment.
- Broad wildcard routes can capture frontend paths unintentionally; the instructor reserves /r/ to avoid ambiguity.
Recall before revealing
Why introduce /r/ before every short-link identifier?
Reveal the explanation
It gives the routing configuration an unambiguous pattern for sending short links to the data service while leaving other application paths with the frontend.
Try it
Assign /app, /api/auth, and /r/example to the appropriate service in the final design.
Check your result
You place application and authentication paths with the user-application Worker and /r/example with the redirect data service.
Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.
Rewatch only what you need
Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.
- 00:02:32 — Custom domains versus routes
- 00:06:07 — Wrong environment selected during stage build
- 00:07:07 — Socket host broken after domain change
- 00:13:13 — Reserve the /r/ redirect prefix
Companion primary documentation: Wrangler environments. For recorded API names, commands, limits, and prices, check the version you use.