> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Gateway Web route families

> Route Web families through the Gateway and coordinate family deployments, route tables, and rollback.

The [Gateway Worker runbook](https://docs.tuturuuu.com/build/devops/gateway-worker.md) covers the
shared-origin routing and activation procedures used by these families.

Route families of `apps/web` built as their own Worker (see
[Web route families on Cloudflare](https://docs.tuturuuu.com/build/devops/web-opennext-families.md)) are
reached through gateway service bindings on the existing `tuturuuu.com/*`
route. Family Workers have no routes, so no zone or DNS change is involved.

* `webFamilies` in `apps/gateway/src/manifest.json` lists each family: `id`,
  `binding` (`WEB_FAMILY_<ID>`), `exact` paths, raw `prefix` entries (each
  ending in `/`), `exclude` subtrees, `localized` and `assetPrefix` (`/_f/<id>`
  for page families, stripped before the family sees the request). Matching is
  method-agnostic.
* `webFamilies.deny` lists subtrees that never reach an OpenNext family,
  whatever the flags say; the vinext table assigns them to `api-ops`, and
  without it they go to `web-rest`: `/api/v1/auth/accounts`, `/api/cron`,
  `/api/notifications/send-immediate`, `/api/v1/infrastructure`,
  `/api/v1/devboxes`, the ChatGPT credential routes and `/_next/image`.
* `GATEWAY_WEB_FAMILIES` (comma-separated ids, default empty) turns families
  on. A listed family serves its paths only when its binding exists;
  otherwise they go to the fallback family `web-rest`.

Order in the handler: loop check, mounts, Marketing origin paths (cached),
then the vinext route table, the OpenNext deny list and first flagged, bound
family, then the bound fallback `web-rest`. `web-rest` needs only its binding,
not a flag. Without it the request answers `503`. Families do not apply the signed-in/RSC/server-action bypass:
those requests are what moves.

The family request keeps method, body, query, cookies, `authorization` and
`cf-connecting-ip`. Client forwarding headers (the list in the mounted-app
section) are stripped, and the gateway sets `x-forwarded-host: PUBLIC_HOST`,
`x-forwarded-proto: https` and `x-gateway-hop: 1`. Next's server-action origin
check relies on this contract. Responses carry `x-gateway-cache: FAMILY` and
`x-gateway-family: <id>`, are never stored in the gateway cache, and keep
`Set-Cookie` and `cache-control` as the family sent them. A throwing binding
answers `502 gateway family unreachable`.

Security header parity: the gateway fills `Strict-Transport-Security:
max-age=63072000` and `Referrer-Policy: same-origin` on family responses that
lack them. It never overrides a header the
family sends (CSP, `X-Frame-Options`, route-specific `Referrer-Policy`) and
adds no `Permissions-Policy`, which the live responses do not carry. The other
live security headers (`X-Content-Type-Options`, `X-XSS-Protection`,
`Expect-CT`, `X-Frame-Options: SAMEORIGIN`) match the zone's "Add security
headers" managed transform and appear on every gateway response today; the
per-family S3 header diff confirms them on family responses. Regression coverage
lives in `apps/gateway/src/web-family.test.ts`.

> [!WARNING]
>
> Known customer-facing bug: the zone's `add_security_headers` managed transform
> forces `X-Frame-Options: SAMEORIGIN` on every `tuturuuu.com` zone response (the gateway and every satellite subdomain) after the Worker
> answers, overriding the `DENY` that repo code sends. SAMEORIGIN breaks
> third-party framing of Forms `embed/*` routes, which deliberately omit the
> header so a host page can frame them. The fix is to disable the transform and
> replace it with a Transform Rule that keeps the other headers. Until then, the
> release smoke (`scripts/native-cutover/smoke-checks.mjs`) accepts SAMEORIGIN
> only when the same response's CSP still carries `frame-ancestors 'none'`;
> `DENY` is accepted, and any other value or a missing header fails.

**Rollback** is the previous gateway version, or the family's previous Worker
version. Enabling a family is a change of the
`GATEWAY_WEB_FAMILIES` repository variable followed by a run of the gateway job,
which adds the family's service binding.

### vinext family route table

The vinext family Workers (`tuturuuu-web-vinext-<id>`, see
[Web vinext Workers](https://docs.tuturuuu.com/build/devops/web-vinext-families.md)) are routed from
`apps/gateway/src/web-routes.generated.json`. It is generated from the app
route entries and `apps/web/cloudflare/vinext/families.json` by
`bun run --cwd apps/web routes:gateway`; a test fails when it is stale.

* Each app route entry is a pattern owned by one family. The gateway picks the
  most specific matching pattern as Next.js does (static segments over
  `[param]` over `[...rest]` over `[[...rest]]`), with an optional leading
  locale for localized routes. Unlisted paths under a family's prefixes stay
  with that family (an unknown first segment is a workspace slug, so it goes
  to `dashboard`). Framework endpoints (`/_next/image`, `/_vinext/*`),
  doubled slashes and backslashes go to the catch-all family `web-rest`.
  Unprefixed `/_next/static/*` and `/_f/<id>/` paths of non-vinext builders
  never reach a vinext family: only pages rendered elsewhere emit them, so they
  keep their own route.
* `api-ops` owns the OpenNext deny list paths, including the ChatGPT
  credential routes.
* Each page family serves its own client assets under `/_f/<id>/`. The path
  reaches the family unchanged, and the family serves it from its own assets.
* A family takes traffic only when its id is in `GATEWAY_WEB_FAMILIES` and
  `WEB_FAMILY_<ID>` is bound; otherwise its paths fall through to the OpenNext
  families and then the bound `web-rest` fallback. The vinext table runs before the OpenNext table, after mounts,
  and not for paths the manifest sends to another configured origin (marketing
  assets and flagged marketing groups).
* Cross-family client navigation is a hard navigation: every family build has
  its own RSC compatibility id, and vinext reloads the page when a response's
  id differs.

Bindings: `WEB_FAMILY_API_OPS`, `WEB_FAMILY_API_CORE`,
`WEB_FAMILY_PUBLIC_AUTH`, `WEB_FAMILY_DASHBOARD_APPS`, `WEB_FAMILY_DASHBOARD`,
`WEB_FAMILY_WEB_REST`. `scripts/ci/gateway-deploy-config.mjs` admits a vinext
id in `GATEWAY_WEB_FAMILIES` only when `families.json` marks it `activated`.
Page families activate after a build with their `/_f/<id>` asset prefix.

All six families are activated and flagged
(`GATEWAY_WEB_FAMILIES=public-docs,api-ops,api-core,public-auth,web-rest,dashboard-apps,dashboard`).
Unprefixed `/_next/static/*` and `/_f/<id>/*` for an id no Worker builds go
to `web-rest`; requests for another host get `503`.

**Uploading a gateway version** (no traffic until it is deployed), from a
clean checkout at a commit on `main`:

```bash theme={null}
node scripts/ci/gateway-deploy-config.mjs capture settings.json   # serving version's bindings
WEB_ORIGIN=<live value> MARKETING_ORIGIN=<live value> GATEWAY_WEB_FAMILIES=<ids> \
  node scripts/ci/gateway-deploy-config.mjs write settings.json apps/gateway/wrangler.deploy.json
cd apps/gateway && wrangler versions upload --config wrangler.deploy.json \
  --tag <sha10> --message "<what changes>"
```

`capture` reads the version that serves traffic (`/deployments`, then
`/versions/<id>`), never `/settings`, and `write` keeps its mounts, services
and variables while adding the flagged family bindings. A version upload
inherits the serving version's secrets, so it needs no `--secrets-file` once
`TRUSTED_PROXY_ORIGIN_SECRET` is live. Read the version back
(`GET .../workers/scripts/tuturuuu-gateway/versions/<id>`) and diff its
binding names against the capture before handing it over.

**Cutover:** deploy the uploaded version at 0%, then smoke with
`Cloudflare-Workers-Version-Overrides: tuturuuu-gateway="<version id>"`. Each
moved path answers with `x-gateway-family: <id>`, and each family serves one
of its `/_f/<id>/_next/static/*` assets. Then move the version to 100%.
**Rollback:** re-assign the previous gateway version. A broken family Worker
rolls back to its own previous Worker version instead (see
[Web vinext Workers](https://docs.tuturuuu.com/build/devops/web-vinext-families.md#deploying-a-family)).
Dropping an id from `GATEWAY_WEB_FAMILIES` sends its paths to `web-rest`,
which does not own them, so it is not a rollback. `write` refuses a
`GATEWAY_WEB_FAMILIES` that omits any id the serving gateway's variable
routes, so the `colab-production` environment variable must list every live
family before CI can write or publish a gateway config.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.