apps/gateway is a Cloudflare Worker routed on tuturuuu.com/*. It serves
anonymous public pages from the Workers Cache API and proxies everything else to
the Vercel production web deployment unchanged. It exists to cut Vercel
serverless and bandwidth cost for traffic that does not need a render.
The Worker is not deployed from source control. The provider owner deploys it
and attaches the route; more specific routes (for example the roadmap Worker on
tuturuuu.com/roadmap*) keep winning over tuturuuu.com/*.
Behavior
- Manifest:
apps/gateway/src/manifest.jsonmaps URL patterns to an origin and a cache class.pageis an anonymous public page,staticis a build or public asset, and anything unmatched isbypass(pure pass-through). A unit test checks that every path inapps/web/src/lib/seo/public-routes.generated.jsonis apageroute, so the manifest cannot drift from the marketing pages. - Cache:
GETandHEADonpageandstaticroutes. Fresh for 5 minutes, then served stale for up to 1 hour while a background refresh runs (X-Gateway-Cache: HIT | STALE | MISS). Only200responses withoutSet-Cookieand withoutVary: *are stored. Pages vary by locale bucket (path prefix, thenNEXT_LOCALE, thenAccept-Language);GETandHEADshare an entry; tracking query parameters (utm_*,fbclid,gclid,msclkid) are not part of the key. - Bypass: non-
GET/HEADmethods,Authorization,Range, RSC requests (RSC,Next-Router-*,Next-Actionheaders or_rscparameter) and, for pages, any session-like cookie (sb-*, names containingsession,authortoken,tuturuuu*,__Secure-/__Host-). Static assets ignore cookies. Bypassed requests are forwarded with method, headers, body and cookies untouched; redirects are not followed andSet-Cookieis returned as sent. - Redirects: a
Locationthat points at the origin host is rewritten toPUBLIC_HOST, because the Next proxy builds absolute redirects from the request host. No other response header is changed exceptX-Gateway-Cache. - Origin
Cache-Control: ignored on cacheable routes by default (dynamic Next pages sendprivate, no-store). SetGATEWAY_RESPECT_ORIGIN_CACHE_CONTROL=trueto honourno-storeandprivate. - Failure: missing
WEB_ORIGINreturns500, an unreachable origin502, and a request that already passed through the gateway (x-gateway-hop)508.
Configuration
No secrets are used. The Vercel origin hostname has to accept requests for its
own host; a custom origin hostname such as
origin.tuturuuu.com must be added
as a domain on the Vercel web project before cutover.
Cutover packet
Deploy (provider owner):tuturuuu.com/* comes from wrangler.jsonc. Record the prior Vercel
production deployment id before the first deploy; Vercel keeps serving
tuturuuu.com unchanged until the route is attached.
Pre-flight smoke against the Worker with the route not yet attached is not
possible, so deploy first with GATEWAY_MODE=passthrough, verify, then switch:
200, second request served
from cache, no Set-Cookie on cacheable responses), the login page, that an
anonymous dashboard path redirects to login on the public host, that session
cookies and Authorization bypass the cache, and that Set-Cookie names match
the origin when --origin is given.
Rollback
- Fastest, keeps the Worker: set
GATEWAY_MODE=passthrough(variable change, no code deploy). The Worker becomes a transparent proxy with no cache reads or writes. - Full removal: delete the
tuturuuu.com/*route (or the Worker) in the Cloudflare dashboard. Traffic returns to the unchanged Vercel deployment. - No purge is needed: cache entries expire within 65 minutes and are
never read in
passthroughmode.
Local checks
Marketing page groups
The gateway can serve a page group from theapps/marketing Worker instead of the Vercel web origin. Each group is one flag.
/changelog, /download, /models, /meet, /meet-together, /portfolio, /qr-generator and /visualizations/* always stay on the web origin.
Two Worker variables control the flip:
MARKETING_ORIGIN: thehttps://origin of the marketing Worker. Without it, every group stays on web.GATEWAY_MARKETING_GROUPS: comma-separated group names served by the marketing origin, for examplelegal,company.
GATEWAY_MARKETING_GROUPS. Cached pages from the other origin are keyed separately and expire within the cache window, so a rollback is complete within one stale period.
Smoke for each group before the next one: anonymous 200 on two paths of the group, x-gateway-cache present, and x-tuturuuu-runtime: native on a cache MISS from the marketing origin.
/assets/* is the Vite build output of the marketing app. It always goes to MARKETING_ORIGIN (cached as static) and falls back to the web origin while MARKETING_ORIGIN is unset. It is not tied to a page-group flag, so rolling a group back does not move /assets/*; Vercel web has no /assets path.