Skip to content

Public demo hub ​

The demo hub at demo.lovely-home.co.uk is an isolated Lovely Home stack for prospects and trial users. It uses username/password login instead of Cloudflare Access, reseeds overnight (London time), and excludes home controls.

Credentials ​

FieldValue
URLhttps://demo.lovely-home.co.uk
Usernamedemo
Passwordlovely-demo
Owner explore PIN1234

Override DEMO_USERNAME / DEMO_PASSWORD when running scripts/set-worker-secrets-from-terraform.mjs demo if you need non-default credentials.

What's included ​

  • Guest home, house guide (including pet care for Bailey), bins, emergency, appliance manuals, weather, and settings (appearance/help/about plus owner panels except guest mode and utilities).
  • Fictional seed data in worker/src/lib/demoSeed.js and worker/fixtures/demo-guide-catalog.json.

What's excluded ​

  • Controls / routines — app hidden; /api/button/* POST blocked on the demo worker.
  • Cloudflare Access — disabled for demo via Terraform access_enabled = false.
  • Destructive admin — backup, restore, factory reset, sitter email changes, and scheduled stay edits return 403 DEMO_READ_ONLY.

Architecture ​

  1. Pages — DEMO_PUBLIC=true enables functions/lib/demoPagesGate.js, which redirects unauthenticated visitors to /sign-in (built from sign-in.html). Do not add _redirects rules for the login path — they conflict with Cloudflare pretty URLs and cause redirect loops.
  2. Worker — DEMO_AUTH_ENABLED=true on the demo Wrangler env; /api/demo/login issues an HttpOnly cookie and a sitter device session.
  3. Reseed — hourly cron (0 * * * *) calls reseedDemoHubIfNeeded(); reseeds once per London calendar day.
  4. Terraform — demo_public: true on demo in platform/sites.yaml marks it a public demo hub. The generated tfvars set access_enabled = false for it, so the module creates no Access apps and puts DEMO_PUBLIC=true on Pages instead of the Access AUD env vars. Without it, any Terraform apply of demo (a provision, or a Move hub database run) puts Cloudflare Access in front of the demo. The same flag tells set-worker-secrets-from-terraform.mjs to set the demo login secrets instead of the Access ones. Registry records rewrite sites.yaml through scripts/lib/write-sites-yaml.mjs, which writes demo_public (and the other registry flags) back, so a provision doesn't drop it (#1160).
  5. Turnstile (#1158) — the credentials are published, so /sign-in shows a Cloudflare Turnstile check and /api/demo/login verifies it (shared helper src/lib/turnstile.js, demo wiring worker/src/lib/demoTurnstile.js). /api/demo/session returns turnstileSiteKey, and the page renders the widget only when it's set. Uses the Lovely Home public forms widget (lovely-home.co.uk covers the demo. subdomain).
    • CI: a browser test can't solve a real challenge. Hub smoke, the demo regression and the marketing screenshots sign in with DEMO_TEST_BYPASS, sent as X-Lovely-Demo-Test-Bypass on the login call only (e2e/lib/demoHub.js). It skips the Turnstile check and nothing else: the password and rate limit still apply.
    • Switching it on: the demo provision sets TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY and DEMO_TEST_BYPASS on the Worker only when all three are set (scripts/lib/demo-turnstile-secrets.mjs); otherwise it warns and Turnstile stays off. DEMO_TEST_BYPASS is a repo secret on home-dashboard (provision, marketing screenshots) and lovely-hub-provision (Hub smoke), with the same value in both. To rotate it, update both, then provision demo.
    • Stale Access secrets: the demo provision deletes CF_ACCESS_AUD, CF_ACCESS_TEAM_DOMAIN and CF_ACCESS_MANAGEMENT_TOKEN from the Worker if they're there.
  6. Demo login rate limit — five failed sign-in attempts per client IP per ten minutes (same durable-object limiter as owner PIN).
  7. Service worker — cache name tracks package.json version; new deployments activate the updated worker and reload open tabs.

Manual reseed ​

After changing demo seed data, force a fresh reset without waiting for the nightly cron or editing D1:

bash
node scripts/reseed-demo-hub.mjs demo

Uses HUB_PROXY_SECRET (from env or terraform output) to call POST /api/demo/reseed on the demo hostname. Deploy the Worker first if you added or changed the reseed route.

Alternatively, clear demoLastReseedDate on the demo D1 site_profile row and reload the hub (the next request triggers ensureDemoHubSeeded).

Rotate demo credentials ​

Set DEMO_USERNAME and DEMO_PASSWORD in the environment when running scripts/set-worker-secrets-from-terraform.mjs demo, then redeploy Worker secrets.

Deploy checklist ​

  1. Merge and deploy Worker: npm run deploy --prefix worker -- --env demo
  2. Deploy Pages project home-dashboard-demo (production branch)
  3. Apply Terraform for demo (access_enabled = false) or run platform provision for demo
  4. Set secrets: node scripts/set-worker-secrets-from-terraform.mjs demo
  5. Attach HUB_API binding if needed: node scripts/attach-hub-api-pages-binding.mjs demo
  6. Visit demo URL, sign in, confirm banner and apps; use PIN 1234 for owner explore

Roll out app version (e.g. 3.7.0) after tag merge ​

When the live hub still shows an older Home Hub version (check Settings → About, or curl -sL https://demo.lovely-home.co.uk/service-worker.js | head -1 for home-dashboard-vX.Y.Z) while main / the tag is newer, roll out Pages and optionally Worker — seed data lives on the Worker, not in the static build.

1. Hub Pages CD (demo only) ​

GitHub → home-dashboard → Actions → CD — Hub Pages → Run workflow:

InputValue
refv3.7.0 (or the release tag / commit SHA on main)
sitesdemo

That job checks out ref, resolves CHECKOUT_SHA, and dispatches hosted CD on marklovely/lovely-hub-provision (needs repo secret PUBLIC_CI_DISPATCH_TOKEN). From a machine with that token:

bash
export CHECKOUT_SHA="$(git rev-parse v3.7.0^{commit})"
export SITES=demo
export PUBLIC_CI_DISPATCH_TOKEN=...   # PAT with actions:write on lovely-hub-provision
node scripts/dispatch-public-hub-cd.mjs

Cloud Agent / CI tokens without workflow_dispatch on the private repo cannot trigger step 1 via gh; use the Actions UI or the dispatch script above.

2. Demo Worker (when seed routes or demoSeed.js changed) ​

bash
npm ci
npm run deploy --prefix worker -- --env demo

Requires Cloudflare credentials (CLOUDFLARE_API_TOKEN, account id) as for normal worker deploys.

3. Force reseed (optional) ​

After Worker deploy, if guest House Guide should match the latest fictional seed (Bailey pets category, etc.):

bash
export HUB_PROXY_SECRET=...   # or: terraform output for demo hub proxy secret
node scripts/reseed-demo-hub.mjs demo

The script requires demo_public: true on the demo entry in platform/sites.yaml. If reseed is skipped, overnight London cron still reseeds once per calendar day.

4. Verify ​

bash
# Pages bundle / service worker cache name tracks package.json version
curl -sL https://demo.lovely-home.co.uk/service-worker.js | rg "CACHE_NAME"

# Signed-in catalog (demo / lovely-demo) — pets area title is "Bailey" (category id `pets`)
curl -sL -c /tmp/demo.jar -b /tmp/demo.jar -X POST \
  'https://demo.lovely-home.co.uk/api/demo/login' \
  -H 'Content-Type: application/json' \
  -d '{"username":"demo","password":"lovely-demo"}'
curl -sL -b /tmp/demo.jar 'https://demo.lovely-home.co.uk/api/house-guide/catalog' | rg '"title":"Bailey"'

Expected UX after rollout: About shows Home Hub v3.7.0; House Guide lists areas including Bailey (Walks • meals • bedtime). Bailey is a guide category, not necessarily a home-screen tile.

Local development ​

Demo auth routes are only active when HUB_ENVIRONMENT=demo and DEMO_AUTH_ENABLED=true on the Worker. The login page is built as dist/sign-in.html (URL /sign-in) via Vite multi-page input.

Troubleshooting redirect loops ​

If the browser shows ERR_TOO_MANY_REDIRECTS on the demo hostname:

  1. Confirm the latest Pages deploy includes sign-in.html and no _redirects file in dist/.
  2. In Cloudflare Pages → home-dashboard-demo → Environment variables: DEMO_PUBLIC=true, and remove CF_ACCESS_* vars if present.
  3. Purge cache for demo.lovely-home.co.uk (Caching → Configuration → Purge Everything) — stale _redirects rules can persist at the edge.
  4. Test with curl (expect 200 on /sign-in, not 308 looping):
    bash
    curl -sI https://demo.lovely-home.co.uk/sign-in | grep -i '^HTTP\|^location'

HTTP 403 / “Access was denied” in Chrome ​

The demo must not use Cloudflare Access (only the in-app username/password gate). A 403 on /sign-in usually means Access env vars leaked onto the demo Pages project, or a stale Zero Trust / WARP session is interfering.

Fix (operator):

bash
CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=... node scripts/ensure-demo-pages-env.mjs
bash scripts/deploy-cloudflare-pages-site.sh demo

Also in Zero Trust → Access → Applications, delete any application still protecting demo.lovely-home.co.uk.

Try (visitor):

  1. Open an Incognito window (or clear site data for demo.lovely-home.co.uk and cloudflareaccess.com).
  2. Temporarily disconnect Cloudflare WARP if you use the Lovely Home Zero Trust team on that machine.
  3. Retry https://demo.lovely-home.co.uk/sign-in