Deploy the Hub
The Hub is a Cloudflare Worker, not a Pages project. Its Worker serves the React
SPA from dist/client; worker/index.ts only proxies /api/ai/* to AI_URL
and otherwise serves static assets.
Configuration model
Tenant configuration is fetched by the browser from the Platform API's
/hub-configs endpoint. The first hostname label selects the organization for
your hub domain, for example acme.weave.host. The Worker has no KV binding and
does not serve a /__config.js endpoint.
The build requires VITE_WORKOS_CLIENT_ID. It can also set these build-time
variables:
| Variable | Default | Purpose |
|---|---|---|
VITE_API_BASE_URL | Platform API production URL | Platform API base URL |
VITE_HUB_DOMAIN | weave.host | Root-domain and organization-host detection |
VITE_DASHBOARD_URL | Dashboard production URL | Dashboard handoff redirects |
AI_URL is the Worker's only runtime variable. Set it in wrangler.jsonc for
each Worker environment.
Build and deploy
@cloudflare/vite-plugin selects the Wrangler environment at build time from
CLOUDFLARE_ENV. Build before deploying; passing --env to the deploy command
does not select the generated configuration.
CLOUDFLARE_ENV=staging VITE_WORKOS_CLIENT_ID=<client id> pnpm exec turbo run build --filter=@loom-loyalty/hub
cd apps/hub && npx wrangler deploy
The build writes a flattened deployment configuration to
dist/loom_loyalty_hub/wrangler.json and a redirect at
.wrangler/deploy/config.json. Deploy from apps/hub after a local build, or
from dist/loom_loyalty_hub when using a downloaded build artifact.
CI deployment paths
- Pull requests upload a Worker version with
wrangler versions upload; CI posts the preview URL to the pull request. - Each push to
mainbuilds and deploys staging and demo using their respectiveCLOUDFLARE_ENVvalues. - Production deploys only on a release merge.
DNS and TLS
Configure a proxied wildcard DNS record for your hub domain. Universal SSL
covers a one-level wildcard such as *.weave.host. A second-level wildcard,
such as *.stage.weave.host, needs an advanced certificate.
Troubleshooting
- If a tenant does not load, confirm the first hostname label is the intended
organization code and that its
/hub-configsrecord exists in the Platform API. - If authentication fails at startup, confirm
VITE_WORKOS_CLIENT_IDwas present when the client bundle was built. - If a deploy targets the wrong environment, rebuild with the intended
CLOUDFLARE_ENV; do not rely on a deploy-time--envflag.