SSR / foldkit-host
What each host part owns
| Part | What it owns |
|---|---|
Host.isolate | Build a value once per binding, retrying if initialization fails |
Host.template | Read /index.html and its build id from assets once per isolate |
Host.routes | Dispatch assets, check ORIGIN, match routes, then run otherwise |
Host.node | Adapt the same handler to Node's http server with origin checks |
Every other concern stays with the package built for it:
- Page routes and status codes belong to your fallback entry (
Site.parsefromfoldkit-siteandSSR.entry'sstatusfromfoldkit-ssr). - Response caching belongs to
SSR.entry'scachefor pages andserveFetch's cache for Remote reads. - Who is asking is resolved per request by
foldkit-auth'sAuthServer.host; nothing insideHost.isolatemay hold a user principal. - Durable Objects and media routes are added in your
routesmap because Workers require Durable Object classes to be exported from your Worker module. - Bindings (
DB,ASSETS, secrets) are declared inwrangler.tomlor your deployment stack before the host runs.
How requests are ordered
A request runs through four stages in fixed order:
- Assets (
/assets/from the binding) run first, so an unconfigured Worker still serves its static build. - Origin check verifies the
ORIGINenvironment variable is set; if missing or empty, it returns500naming the variable. Configured explicitly rather than read from the request header so a Worker reachable on a second host (likeworkers.dev) trusts only its configured origin. - Routes match in order (
'/auth/'by prefix,'/remote'by exact path). - Fallback (
otherwise) renders the page.