Cloudflare Worker that routes incoming requests to deco storefront workers using Workers for Platforms dispatch namespaces.
This is the dispatch worker — a single Cloudflare Worker that sits in front of all deco storefront workers and routes requests to the correct one based on the hostname.
*-tanstack.deco.site subdomains:
- Extract subdomain from hostname (e.g.,
mysite-tanstack.deco.site→mysite-tanstack) - Strip the
-tanstacksuffix →mysite - Dispatch to the user worker named
mysitein the namespace
Custom domains:
- Look up the hostname in the
DOMAIN_MAPKV namespace - Get the site name from the KV value
- Dispatch to the corresponding user worker
This worker only handles requests matching the *-tanstack.deco.site/* route pattern. It does not interfere with other *.deco.site subdomains.
| Binding | Type | Description |
|---|---|---|
DISPATCHER |
Dispatch Namespace | The deco-storefronts namespace containing all user workers |
DOMAIN_MAP |
KV Namespace | Maps custom domain hostnames to site names |
See wrangler.jsonc for the full worker configuration. You'll need to replace placeholder values:
<kv-namespace-id>— Your KV namespace ID for domain mapping
npx wrangler deployRequest → Cloudflare Edge
→ Route match: *-tanstack.deco.site/*
→ cf-dispatch worker
→ DISPATCHER.get(siteName)
→ User's storefront worker
→ Response
MIT