SSR / foldkit-host
With Remote, auth and pages
In examples/reference, AuthServer.host is built
once per D1 binding inside Host.isolate, returning Yielded Auth's /auth/
routes, the scripted resolver for serveFetch, and the navigation resolver for
pageReader:
ts
export const worker = Host.routes({
origin: 'ORIGIN',
assets: { at: '/assets/', binding: (env: AppEnv & { readonly ASSETS: Host.Assets }) => env.ASSETS },
routes: {
'/auth/': async (request, env) => (await hostOf(env)).auth(request),
'/remote': async (request, env) => (await hostOf(env)).remote(request, env),
},
otherwise: async (request, env) => (await hostOf(env)).page(request, env),
})If you add a Sync WebSocket route here, use AuthServer.resolver({ requests: 'browser', … })
rather than host.scripted: browser WebSocket upgrades carry Origin but
cannot send custom CSRF headers.