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 returns 500 naming the missing variable, on both Workers and Node. There is no fallback to the request's Host header.
  • 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 ran vite build with Host.buildTag.

Limits

  • One ORIGIN per deployment.
  • No all-in-one preset: your Worker writes its own Host.routes call from these parts.

Next