SSR / foldkit-host
On Node
Host.node runs the same handler on Node's http server for development and
tests, passing a fixed env:
ts
import { createServer } from 'node:http'
const env = { DB: { prepare: () => undefined }, ORIGIN: 'http://localhost:3000' }
createServer(Host.node(answer, { env, origin: 'ORIGIN' }))Because Node passes a raw request target rather than a parsed Request,
Host.node resolves it against env.ORIGIN using Foldkit's
resolveRequestUrl and rejects targets pointing to another host with 400.
Your handler receives a standard Request whose signal aborts if the client
disconnects, cancelling streamed responses like live reads.
Thrown errors are logged and answered with a fixed 500 response body so
internals never leak. Request bodies are buffered up to maxBodyBytes (32 MiB
by default) and rejected above that limit with 413; use Host.node for
development and tests rather than public internet traffic.
Failure and recovery
- Unset
ORIGIN: Every non-asset request returns500naming the missing variable, on both Workers and Node. There is no fallback to the request'sHostheader. - Failed isolate build: Unmigrated databases or missing assets fail all concurrent callers waiting on that initialization and clear the entry so the next request retries.
- Missing template or build id: Page requests fail with an error naming
/index.html; ensure your build ranvite buildwithHost.buildTag.
Limits
- One
ORIGINper deployment. - No all-in-one preset: your Worker writes its own
Host.routescall from these parts.
Next
- Serve pages rendered on the server:
foldkit-ssr - Sign people in and resolve principals:
foldkit-auth - See a full Worker wired with these parts:
examples/reference