Skip to content
Engineering1 min read

Deployment

Static pre-rendering, Cloudflare Workers static assets, headers, redirects and custom domains.

Updated Nov 1, 20251 min readEdit this page
On this page

The site has no runtime server. react-router build pre-renders every route into build/client; Cloudflare Workers serves those files as static assets and only unknown URLs fall back to the generated 404.html.

Build#

Local verificationbash
npm installnpm run typechecknpm run testnpm run buildnpm run preview   # Wrangler serves build/client

The build output contains one HTML file per route plus React Router's .data files for client navigation. Do not flatten or rename these files.

Cloudflare Workers#

  1. 1

    Create the Worker

    In the Cloudflare dashboard, create a Worker under Workers & Pages and connect it to this repository.

  2. 2

    Set build and deploy

    Build command npm run typecheck && npm test && npm run build, deploy command npx wrangler deploy, Node 22.

  3. 3

    Any domain works

    No build variables: the origin of canonical, OG, JSON-LD and sitemap URLs is replaced at the edge with the request domain, so *.workers.dev, preview URLs and custom domains all work as-is.

  4. 4

    Deploy

    Push to main, or run npm run deploy with Wrangler authenticated locally.

wrangler.tomltoml
name = "lumo-website"main = "./src/worker.ts"compatibility_date = "2025-01-01" [assets]directory = "./build/client"binding = "ASSETS"html_handling = "auto-trailing-slash"not_found_handling = "404-page"run_worker_first = true

Headers and redirects#

FilePurpose
public/_headersSecurity headers and immutable asset caching.
404.html (generated)Branded 404 response for unknown URLs; known routes are served from their own HTML files.
public/robots.txtCrawler policy and sitemap location.
scripts/build-sitemap.mjsWalks the pre-rendered HTML and writes sitemap.xml.

Order matters

Cloudflare Workers static assets serve an existing file first. If a route 404s, check that its pre-rendered HTML exists before changing the 404 fallback.

Custom domain#

  1. Add the domain under Worker → Settings → Domains & Routes and follow the DNS instructions.
  2. Switching domains needs no reconfiguration: canonical and sitemap URLs follow the request domain.
  3. Submit the generated sitemap.xml in Search Console.