Skip to main content

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:

VariableDefaultPurpose
VITE_API_BASE_URLPlatform API production URLPlatform API base URL
VITE_HUB_DOMAINweave.hostRoot-domain and organization-host detection
VITE_DASHBOARD_URLDashboard production URLDashboard 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 main builds and deploys staging and demo using their respective CLOUDFLARE_ENV values.
  • 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-configs record exists in the Platform API.
  • If authentication fails at startup, confirm VITE_WORKOS_CLIENT_ID was 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 --env flag.