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
| Field | Value |
|---|---|
| URL | https://demo.lovely-home.co.uk |
| Username | demo |
| Password | lovely-demo |
| Owner explore PIN | 1234 |
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.jsandworker/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
- Pages —
DEMO_PUBLIC=trueenablesfunctions/lib/demoPagesGate.js, which redirects unauthenticated visitors to/sign-in(built fromsign-in.html). Do not add_redirectsrules for the login path — they conflict with Cloudflare pretty URLs and cause redirect loops. - Worker —
DEMO_AUTH_ENABLED=trueon thedemoWrangler env;/api/demo/loginissues an HttpOnly cookie and a sitter device session. - Reseed — hourly cron (
0 * * * *) callsreseedDemoHubIfNeeded(); reseeds once per London calendar day. - Terraform —
demo_public: trueondemoinplatform/sites.yamlmarks it a public demo hub. The generated tfvars setaccess_enabled = falsefor it, so the module creates no Access apps and putsDEMO_PUBLIC=trueon 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 tellsset-worker-secrets-from-terraform.mjsto set the demo login secrets instead of the Access ones. Registry records rewritesites.yamlthroughscripts/lib/write-sites-yaml.mjs, which writesdemo_public(and the other registry flags) back, so a provision doesn't drop it (#1160). - Turnstile (#1158) — the credentials are published, so
/sign-inshows a Cloudflare Turnstile check and/api/demo/loginverifies it (shared helpersrc/lib/turnstile.js, demo wiringworker/src/lib/demoTurnstile.js)./api/demo/sessionreturnsturnstileSiteKey, and the page renders the widget only when it's set. Uses the Lovely Home public forms widget (lovely-home.co.ukcovers thedemo.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 asX-Lovely-Demo-Test-Bypasson 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_KEYandDEMO_TEST_BYPASSon the Worker only when all three are set (scripts/lib/demo-turnstile-secrets.mjs); otherwise it warns and Turnstile stays off.DEMO_TEST_BYPASSis 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 provisiondemo. - Stale Access secrets: the demo provision deletes
CF_ACCESS_AUD,CF_ACCESS_TEAM_DOMAINandCF_ACCESS_MANAGEMENT_TOKENfrom the Worker if they're there.
- CI: a browser test can't solve a real challenge. Hub smoke, the demo regression and the marketing screenshots sign in with
- Demo login rate limit — five failed sign-in attempts per client IP per ten minutes (same durable-object limiter as owner PIN).
- Service worker — cache name tracks
package.jsonversion; 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:
node scripts/reseed-demo-hub.mjs demoUses 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
- Merge and deploy Worker:
npm run deploy --prefix worker -- --env demo - Deploy Pages project
home-dashboard-demo(production branch) - Apply Terraform for demo (
access_enabled = false) or run platform provision fordemo - Set secrets:
node scripts/set-worker-secrets-from-terraform.mjs demo - Attach HUB_API binding if needed:
node scripts/attach-hub-api-pages-binding.mjs demo - Visit demo URL, sign in, confirm banner and apps; use PIN
1234for 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:
| Input | Value |
|---|---|
ref | v3.7.0 (or the release tag / commit SHA on main) |
sites | demo |
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:
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.mjsCloud 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)
npm ci
npm run deploy --prefix worker -- --env demoRequires 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.):
export HUB_PROXY_SECRET=... # or: terraform output for demo hub proxy secret
node scripts/reseed-demo-hub.mjs demoThe 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
# 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:
- Confirm the latest Pages deploy includes
sign-in.htmland no_redirectsfile indist/. - In Cloudflare Pages →
home-dashboard-demo→ Environment variables:DEMO_PUBLIC=true, and removeCF_ACCESS_*vars if present. - Purge cache for
demo.lovely-home.co.uk(Caching → Configuration → Purge Everything) — stale_redirectsrules can persist at the edge. - Test with curl (expect 200 on
/sign-in, not 308 looping):bashcurl -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):
CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=... node scripts/ensure-demo-pages-env.mjs
bash scripts/deploy-cloudflare-pages-site.sh demoAlso in Zero Trust → Access → Applications, delete any application still protecting demo.lovely-home.co.uk.
Try (visitor):
- Open an Incognito window (or clear site data for
demo.lovely-home.co.ukandcloudflareaccess.com). - Temporarily disconnect Cloudflare WARP if you use the Lovely Home Zero Trust team on that machine.
- Retry https://demo.lovely-home.co.uk/sign-in