Server sites (Next.js / OpenNext) on <slug>.devstack.bid
On this page
Static builds are stored in R2 and served by devstack-sites. Apps that need a server
(Next.js with API routes, SSR, middleware) are uploaded as user Workers into a single
Workers for Platforms dispatch namespace (SITES_DISPATCH_NAMESPACE) — one namespace,
many scripts — not one standalone account Worker per project.
Why WfP#
- Account Workers-per-project hit Cloudflare limits and complicate routing.
- WfP dispatch namespaces are the supported multi-tenant model.
deployServerWorkerrequiresdispatchNamespaceunlessallowLegacyWorkers: true(tests / emergency only). Production hosting fails closed withwfp_requiredwhen the namespace env is unset.
Flow#
- Build container (
container/build-server.mjs) runs install + build. For Next.js the build command isnpx opennextjs-cloudflare build, output.open-next. - If the output has
.open-next/worker.js(and noindex.html), the container runswrangler deploy --dry-runto produceworker/worker.js+assets/**+server.json. - Platform (
src/lib/hosting/server-worker.ts) wraps the module in the guard, thenPUT /accounts/:id/workers/dispatch/namespaces/:ns/scripts/:namewith assets upload. publishServerwriteshosts/<label>.jsonwith{ worker: "site-<hash>" }.devstack-sitesroutes SSR hosts via theDISPATCHERbinding to namespacedevstack-sites.
Script names remain site-<hash(projectId)> (production) and
site-<hash(projectId)>-<hash(deploymentId)> (preview).
Env (platform Worker)#
| Var | Role |
|---|---|
SITES_CF_ACCOUNT_ID |
Account id |
SITES_CF_API_TOKEN |
Token with dispatch-namespace script edit |
SITES_PROXY_SECRET |
HMAC for guard (≥32 chars) |
SITES_DISPATCH_NAMESPACE |
Required for SSR hosting uploads |
GO required#
Dispatch namespace devstack-sites + DISPATCHER binding on the serving Worker are provisioned
with owner GO (see DEVSTACK-HOSTING.md).
Source: docs/platform/SERVER-SITES.md · /docs/platform/server-sites.md