ReferenceAsk
Remy Reference/Architecture/Architecture/Edge and Custom Domains
26Architecture

Edge and Custom Domains

The Cloudflare Workers that make up the edge, the small hostname-to-parameters routing contract they implement, how a customer's own domain is carried with an automatic certificate, and what the edge caches.

Every browser request, whether to a deployed app, the editor, the console, a file, an image, or a video, arrives at Cloudflare first. The edge is made up of a set of Workers, each owning a hostname pattern, and Cloudflare for SaaS carries customers' own domains, with certificates issued automatically. This chapter covers the Workers, the routing contract they implement, custom domains, and what the edge caches.


#The Workers

WorkerHostnamesWhat it does
agent-subdomain-proxy*.madewithremy.com, the legacy app apex, the Cloudflare for SaaS fallback and CNAME targetsResolves the app from the subdomain label or the custom hostname and reverse-proxies to the platform
sandbox-preview-proxy*.remy-sandbox.comFronts dev-box previews and hot reload, forwarding to the sandbox-proxy role
mscdn-rewriteThe git host and release-addressed static hostsRoutes git traffic to the git role with per-app stickiness, and static assets to the release-addressed origin
api-host-rewriteThe public API hostnameProxies to the API origin with CORS and edge caching for cacheable reads
ws-host-rewriteA legacy socket aliasProxies WebSocket upgrades to the socket origin
files-cdn-host-rewriteThe files CDN hostsServes public files from the public buckets with content-type inference and audio waveform rendering
image-cdn-qs-rewritesThe image CDN hostsServes images from the regional public buckets with edge transformation from query parameters
videos-cdnThe video CDN hostsServes video with range support, frame thumbnails and metadata

The Workers are one package with their own build, tests, and deploy scripts. Each deploys to the zones it owns.


#The Routing Contract

The platform is edge-agnostic. It reads the app's identity and the request path from query parameters and never from the Host header. The Worker's job is to map a hostname to those parameters:

IncomingForwarded to the platform
<sub>.<apex>/*custom-subdomain/serve?subdomain=&path=
<sub>.<apex>/_/*custom-subdomain/proxy?subdomain=&path=
<customer-domain>/*custom-host/serve?host=&path=
<customer-domain>/_/*custom-host/proxy?host=&path=

A page load is serve; anything the app's frontend calls under the internal prefix is proxy, and the platform's segment switch dispatches from there. The app-facing query string rides along. HTTPS is forced unconditionally before any other handling, and the redirect target is built from the client-facing host so a custom domain redirects to itself.

Because the contract is this small, any reverse proxy can implement it. The Workers in the cloud, an ALB or CloudFront in a dedicated account, and a Caddy configuration on a laptop are three implementations of one mapping. See Portability.


#Custom Domains

A workspace attaches its own domain to an app. The platform registers it as a Cloudflare for SaaS custom hostname; the customer points a CNAME at the platform's target; Cloudflare validates ownership by HTTP, TXT, or delegated validation and issues and renews the certificate. Traffic for the custom hostname terminates at Cloudflare and is forwarded to the Worker's fallback origin with the original hostname preserved, so the Worker routes it like any other app.

A domain and its www alias are managed as a pair. API calls on either are routed to the app directly; page navigation canonicalizes to the primary so there is one address for search engines and one for cookies. Custom hosts always serve the live release; previews live only on the platform apex.


#What the Edge Caches

The caching split is a property of the response, and the Worker honors it:

  • Session HTML is never cached. Every page load reaches the platform and gets the session injected.
  • Content-addressed assets from a release's build are cached at the edge for a long time; a new release has new addresses.
  • Public files are cached at the edge under a content-addressed CDN key after transformation; the platform's redirect that locates them is cached briefly.
  • Private files and per-user transforms are never cached.
  • Public API reads are edge-cached when the origin says so, with browser caching forced to revalidate so a client never sees a stale read after its own write.

The platform purges by tag when a cached payload changes: after every deploy for the compile-time payloads, and on demand when an app's public file or prerendered page changes.


#The Frontends

The Remy editor and console are static builds deployed as Cloudflare Workers, with their assets on the same edge, and they call the platform's API and WebSocket hosts directly.

What This Gives an App
A global edge in front of every request, with TLS terminated close to the user.
Its own domain with a certificate it never manages.
Assets and public files served from cache; personalized pages always fresh.
An origin that can sit behind a different edge without changing.