Skip to content

Deploying ​

How to put the demo on Cloudflare. A person runs these commands on their own computer; nothing deploys from CI yet, and nothing here should be pasted into a pull request, a commit or an issue with real values in it.

The generated file is never committed

apps/worker/wrangler.generated.jsonc holds one deployment's own ids. It is gitignored (*.generated.jsonc), and the generator refuses to overwrite a file it didn't write, so it can never replace wrangler.jsonc.

Two kinds of config ​

(Three, if you count the public demo: it has no Access, no database and no Worker code, and is a section of its own below.)

  • apps/worker/wrangler.jsonc is for local development and the tests only: a stub login (AUTH_MODE=stub), the X-Now clock override (NOW_OVERRIDE=allowed) and a placeholder database. It stays free of account ids and secrets, and it is never used to deploy.
  • apps/worker/wrangler.generated.jsonc is for a deployment. npm run config:generate writes it from three settings. It sets two variables, TEAM_DOMAIN and POLICY_AUD, and never AUTH_MODE or NOW_OVERRIDE, so every login is verified against Cloudflare Access and the dev routes and the clock override stay off. Tests keep that true. It also binds the nightly backup's R2 bucket as BACKUPS, turns on Workers Issues (error alerts) and sets one hourly Cron Trigger (0 * * * *, UTC) in both modes. The demo gets it too: it is the one place the backup and the restore drill run on a real bucket and database before production. It holds no secret: the backup's encryption key, BACKUP_KEY, is a Worker secret you set with wrangler secret put (step 5).
SettingWhat it isThe generator refuses when
D1_DATABASE_IDThe database's id, from wrangler d1 createmissing or empty; not a lowercase UUID
TEAM_DOMAINhttps://<team>.cloudflareaccess.commissing or empty; any other shape (path, trailing slash, port, capitals, http)
POLICY_AUDThe Access application's audience tag (64 lowercase hex digits)missing or empty; not 64 hex digits; pending anywhere but demo mode
CUSTOM_DOMAINOptional. A bare hostname for the Worker, like app.example.comset but empty; not a lowercase hostname of at least three parts (see Custom domain); a workers.dev address
--modedemo or productionmissing or anything else
the output filewrangler.generated.jsonc next to wrangler.jsoncit exists and its first line isn't the marker the generator writes

A refusal prints a plain message, exits with an error and writes nothing; so does a file problem (the output is a folder or a symbolic link, its folder is missing or read-only). The file is written readable by its owner only. --out <name>.generated.jsonc exists for the tests: wrangler reads main, the assets and the migrations relative to the config file, so a deploy config belongs in apps/worker, where the default puts it.

ModeWorker nameworkers.dev addressPreview URLsBackup bucket (BACKUPS)
demohome-budget-demoon (Access protects it)offhome-budget-demo-backups
productionhome-budgetoffoffhome-budget-backups

The two names differ, so deploying one can never overwrite the other (and each mode has its own backup bucket). Both modes turn Workers observability on (with Issues) and leave source maps out of the Worker upload.

Production mode has workers_dev off and, unless you set CUSTOM_DOMAIN, no routes, so a production Worker is unreachable until a production runbook (its routes and Access application) exists. Use demo for now.

Before you start ​

  • A Cloudflare account with Zero Trust turned on. The first time you open Zero Trust the dashboard asks for a team name: that is <team> below (your team domain is https://<team>.cloudflareaccess.com). Step 4 needs it, and it must exist before step 10.
  • Node 24 (node -v) and the repository's packages: npm ci at the repository root.
  • A bash or zsh shell. NAME=value command sets a variable for one command there. (PowerShell and cmd.exe don't read that form: use WSL or Git Bash.)

Deploy the demo ​

The demo database holds only the fictional Addams household. Use <team>, <database_id> and <aud tag> below as the placeholders they are: type your own values on your own computer.

  1. Sign in to Cloudflare in the browser:

    sh
    npx wrangler login
  2. Create the demo database, from the repository root. Note the database_id it prints. If it offers to add the binding to a config file, answer no: the generated config is the only one a deployment uses.

    sh
    npx wrangler d1 create home-budget-demo
  3. Create the bucket the nightly backup writes to (R2 may need switching on for the account first, in the dashboard's R2 object storage page; unconfirmed). Use the name for the mode you deploy, from the table above, and Standard storage. The deploy in step 9 fails if the bucket isn't there:

    sh
    npx wrangler r2 bucket create home-budget-demo-backups --storage-class Standard

    If it offers to add the binding to a config file, answer no.

  4. Generate the config. The audience tag doesn't exist yet, so use pending (allowed in demo mode only; until it is replaced, the Worker rejects every login):

    sh
    D1_DATABASE_ID=<database_id> TEAM_DOMAIN=https://<team>.cloudflareaccess.com POLICY_AUD=pending \
      npm run config:generate -w @home-budget/worker -- --mode demo
  5. Set the backup's encryption key, before the first deploy. Make 32 random bytes in base64, put the result in your password manager before you go on (lose it and every backup is unreadable; see the runbook), then give it to the Worker and paste it when asked. Don't type it into the command line, a file in the repository or a chat:

    sh
    openssl rand -base64 32
    npx wrangler secret put BACKUP_KEY -c wrangler.generated.jsonc

    Why before the deploy: the generated config carries the hourly Cron Trigger, so the first deploy starts it, and a tick in the backup's window (04:00 to 10:00 household time) without a key fails. Whether wrangler secret put works for a Worker that doesn't exist yet is unconfirmed (a documentation search found nothing either way). If it refuses or asks to create the Worker, you have two choices: let it, or skip this step, deploy (step 9) and run the same secret put straight away. A miss costs at most one night, and only if the key is set more than 6 hours after the backup hour: a failed tick leaves the day free, and the next hourly ticks try again. A failed night shows up as a failed invocation in the Worker's Issues (Scheduled job failed: backup (BackupError: key_missing)), a failed@backup@... line in the audit log and no new file in the bucket. Until the key is set the backup writes nothing: it never writes an unencrypted copy. The runbook has the rest (the restore drill, alerts, the monthly off-site copy).

  6. Build the app for the API, from the repository root. The default build runs on in-memory mock data and talks to no server, so it would look fine and prove nothing. Then go to the Worker folder for the rest:

    sh
    VITE_DATA_SOURCE=api npm run app:build
    cd apps/worker

    The build also writes source maps (dist/*.map). They are served as public static files like the rest of dist; the source is public anyway. "Source maps left out" in the modes section covers only the Worker's own upload.

  7. Create the tables (it asks you to confirm):

    sh
    npx wrangler d1 migrations apply DB --remote -c wrangler.generated.jsonc
  8. Load the fictional household:

    sh
    node scripts/write-seed-sql.mjs && npx wrangler d1 execute DB --remote --file=.wrangler/seed.sql -c wrangler.generated.jsonc
  9. Deploy:

    sh
    npx wrangler deploy -c wrangler.generated.jsonc

    Until step 11 is done nobody can sign in: the Worker answers 401 everywhere except /api/health. Until step 10 the app's static files (no household data) are public on the Worker's own address; the API already answers 401 without a valid Access token.

  10. Protect the Worker behind Access, in the Cloudflare dashboard: Workers & Pages, open the Worker, the Access tab, Protect this Worker behind Access. Choose All traffic. (Cloudflare's documentation describes Previews only as covering preview addresses, not the production workers.dev address; not tried on an account.) Set who may sign in in the policy it creates.

  11. Copy the application's audience tag: Zero Trust, Access controls, Applications, the new application, Edit, Additional settings. Generate again with the real tag and deploy again (you are still in apps/worker; npm run -w works from any folder):

    sh
    D1_DATABASE_ID=<database_id> TEAM_DOMAIN=https://<team>.cloudflareaccess.com POLICY_AUD=<aud tag> \
      npm run config:generate -w @home-budget/worker -- --mode demo
    npx wrangler deploy -c wrangler.generated.jsonc
  12. Link each person to their Access login. The Worker matches the token's sub claim to the person's access_subject; a login that matches nobody is a 403. First sign in to the Worker's address once, so Access sets its cookie. Then read your own sub from the CF_Authorization cookie (browser dev tools, Application or Storage, Cookies).

    That cookie is a live credential: anyone holding it can act as you until it expires. Keep it off the command line (shell history and process lists show those), out of chats, tickets and online decoders. The first command waits for you to paste the cookie value and press Enter (nothing is shown); then the token is decoded on your computer and forgotten:

    sh
    read -rs T
    echo
    T="$T" node -e "console.log(JSON.parse(Buffer.from(process.env.T.split('.')[1], 'base64url')).sub)"
    unset T

    Then, still in apps/worker, once per person (<id> is the person's id in the people table):

    sh
    npx wrangler d1 execute DB --remote -c wrangler.generated.jsonc \
      --command "UPDATE people SET access_subject = '<sub>' WHERE id = '<id>'"

    The seed pre-fills placeholder subjects (dev-<id>) that Access never issues; this step replaces them.

  13. Check it works. Open the Worker's address in a private window. ✅ Access asks you to sign in first, then the dashboard shows the household. ✅ In the browser's network tab the page's requests go to /api/... (a mock build makes none). ✅ A signed-in person who isn't linked yet gets a 403 from /api/me, not a dashboard.

  14. Check the deployed site from the outside, as a stranger. See the next section.

  15. Real data (production only, never the demo): the checked local import goes up as one SQL file that you load with your own commands. Migrate the database first (step 7 with the production config), then follow Loading it into the real app. Use a production config for it (--mode production): the steps above are the demo's, and the demo's database must never get real data.

Deploying again later: step 4 (only if a setting changed), the build in step 6, then step 9, then the check below. The bucket (step 3) and the key (step 5) are one-time.

Public demo ​

The demo above (--mode demo) sits behind Cloudflare Access, talks to a real D1 database and links a real person's login to a made-up household. That is fine for trying the stack, and wrong for strangers: the database holds that login, the Worker holds a backup and SimpleFIN code, and every one of those is something to defend. The public demo is the other answer: take everything away, so there is nothing to defend.

--mode public-demo writes an assets-only config: the built files in apps/web/dist and nothing else. No Worker code runs (there is no main), and the config has no database, bucket, Cron Trigger, variable or secret, so a visitor can only ever be given a file. The files are the default (mock) build: the made-up Addams household, "Log in as Gomez" and "Log in as Morticia" buttons (the visitor picks who they are; nobody is signed in), and every change a visitor makes lives in their own browser tab and is gone on reload. Nothing is sent anywhere, so nothing can be stored, abused or leaked.

A stranger asks for…What happens
a page or a filethe built file (an unknown address gets the app's home page, the app routes itself)
/api/... (the real app's API)a 404 or the app's home page, never data: no Worker is there to answer it
adding, undoing, moving money, a SimpleFIN tokenhappens in the tab only (the in-memory demo); nothing leaves the browser
a cookie, a login, an accountnone is set or needed

The Worker's name is the same as the Access-protected demo's (home-budget-demo), so one deploy replaces that Worker: its code, database binding, backup bucket binding and hourly trigger go (the config lists an empty schedule on purpose: Wrangler leaves a Worker's schedules alone when none is listed), and the files stay. Its secrets stay (Wrangler keeps them across a deploy), which is why step 6 deletes them. Only the demo can be switched this way; --mode production is untouched.

Put the demo up for everyone ​

Use <demo host> for the hostname you want (CUSTOM_DOMAIN is optional: without it the demo stays on its workers.dev address). Run these on your own computer, from the repository root.

  1. Build the demo files with the public demo build, never VITE_DATA_SOURCE=api (that build looks for a server that isn't there):

    sh
    npm run app:build:public-demo

    It is the plain demo build plus one thing: the household follows today's date (see "How the demo keeps up with the calendar"). The plain npm run app:build also works and shows the same household frozen on Thursday 3 December 2026.

  2. Write the config. It needs no database id, team name or audience tag; if they are set in your shell they are ignored:

    sh
    CUSTOM_DOMAIN=<demo host> npm run config:generate -w @home-budget/worker -- --mode public-demo
  3. Deploy it:

    sh
    cd apps/worker
    npx wrangler deploy -c wrangler.generated.jsonc

    Wrangler may ask you to confirm that bindings and the trigger are being removed: yes, that is the point. (Checked here: wrangler deploy --dry-run reads the file and finds no bindings, and wrangler dev serves it. Unconfirmed: a real deploy over a Worker that had code, a database and a trigger.) If Access still covers the host, visitors still meet a login until step 4.

  4. Take Cloudflare Access off the demo only: Zero Trust, Access controls, Applications, the demo's application. Remove the Worker's and the demo host's destinations, or delete the application (it is the only one that covered the demo). Never touch the production Worker's application. Do this after step 3, so no moment exists where the old API and an open door are both there.

  5. Check it as a stranger. Open https://<demo host> in a private window: ✅ the page opens with no login, ✅ the footer reads "Demo data: nothing you do here is saved." Then:

    sh
    npm run security:check:public -- https://<demo host>

    ✅ Every line PASS and RESULT: PASS (21 of 21 checks). A FAIL line says in words what it saw: "Access is still in front" means step 4 isn't done; "API build" means step 1 used the wrong build. The check sends GET requests only, with no cookie or token, and never prints a body.

  6. Wipe what the old demo kept. None of it is reachable any more, but it still exists in your account, and it holds the login you linked in step 12 of "Deploy the demo":

    • the D1 database: npx wrangler d1 delete home-budget-demo
    • the backup bucket: empty it, then npx wrangler r2 bucket delete home-budget-demo-backups (the dashboard's R2 page can empty it in one go)
    • the Worker's secrets, if you set them: npx wrangler secret delete BACKUP_KEY --name home-budget-demo, and the same for SETTINGS_KEY (unconfirmed on a Worker that no longer has code; the dashboard's Worker settings can delete a secret too)
    • the Access application and its policies (the allowed emails are in the policy), if step 4 left it in place

    Access's own sign-in logs are Cloudflare's and expire there; this repository can't delete them.

  7. Optional, at the Cloudflare edge (a WAF rule can't be written here): ✅ Always Use HTTPS on, ✅ minimum TLS 1.2, and a rate limiting rule on the demo host for one visitor's requests per minute. Files are served by Cloudflare without running any code, so there is no compute for a visitor to run up; the rule only caps how hard one address can hammer it. (Plan limits for rate limiting rules: not checked.)

To go back to the Access-protected demo, run "Deploy the demo" again from step 2 (the database and bucket were deleted in step 6, so they need creating again).

How the demo keeps up with the calendar ​

The made-up household is written for one Thursday (3 December 2026). The public demo build (npm run app:build:public-demo) moves all of it forward by whole weeks when a visitor opens the page, so "today" is the latest Thursday on or before the real day (the household's New York day, not the visitor's). Nothing is rebuilt or redeployed: the files are the same every day and the browser does the arithmetic, so the demo reads as this week without anyone touching it.

  • Whole weeks keep every weekday and every every-N-weeks rhythm (paydays, the set-aside, the manicure) as written, measured from "today": the next payday is always the day after the demo Thursday, so the demo always has a payday coming and a good verdict. Against the calendar the fortnight can start a week later, so a payday that lands on a bank holiday does so only in some weeks; when it does, it sits on the business day before it, as the forecast would put it (a payday on Friday 25 December is paid on Thursday 24 December).
  • Monthly and yearly rules (the gallery on the 15th, the electric on the 20th, the insurance on the last day) and settings that take effect from a day (the set-aside change on 1 January 2027) stay on the calendar, and the app works them out for the new day itself. The amount of the set-aside therefore changes on 1 January 2027 whatever week the demo is on, for the planned one as for the ones the forecast adds.
  • The bank was "read this morning" and the savings balance "as of today" on every visit.
  • Scenario switches (?mock=stale, ?mock=unlocked ...) and a clock in the address (?now=...) are exactly what they say: they keep the fixtures' own dates.
  • The default build (npm run app:build), the tests, the accessibility check and the browser tests never follow today, so they read the same dates on every day they run. A test says so: only --mode publicdemo hands the real moment to the demo.
  • Each week's numbers differ a little (the month's rules fall on different days), and a visit that spans midnight keeps the day it opened on until the page is reloaded. Money in the demo is made up either way.

What the public demo does not do ​

  • It does not prove the API, the database, the backup or the Access login work: nothing runs them. Use the Access-protected demo for that, before production. The two use the same Worker name, so only one is deployed at a time.
  • It does not hide the source: the repository is public and the built files carry source maps.
  • Search engines may index it (no noindex is sent, except on /gallery). To stop that, add X-Robots-Tag: noindex to /* in apps/web/public/_headers (the production app is behind Access anyway).

Landing page ​

The landing page (apps/landing, ADR 0022) is two static pages, the front door and a 404, with no script and no API. It has its own assets-only Worker, budget-bob-landing, and its own config, apps/landing/wrangler.jsonc, which holds no account id, host name, binding or secret (a test checks that). It is meant for the bare domain and www.

Use <demo address> for the demo's address and <bare domain> for your domain. Run these on your own computer, from the repository root.

  1. Build it with the demo's address. The page links to the demo, and a public repository can't carry that address, so the deploy build refuses to run without it:

    sh
    VITE_DEMO_URL=<demo address> npm run landing:build:deploy

    The address is https:// plus a host, nothing after it. A plain npm run landing:build uses a placeholder and is for checking only.

  2. Check it as a stranger would get it (starts wrangler dev on port 8797, or LANDING_A11Y_PORT):

    sh
    npm run landing:a11y
  3. Deploy it. Wrangler is installed in the worker workspace only, so this runs it from there, against the landing config:

    sh
    npm run landing:deploy
  4. Put the domains on the Worker, in the Cloudflare dashboard: Workers & Pages, budget-bob-landing, Domains, add a custom domain for <bare domain> and another for www.<bare domain>. Cloudflare adds the DNS records itself. If the bare domain has an old redirect to the app (a redirect rule or a Bulk Redirect), remove it first, or it will win.

  5. The Worker also answers on its workers.dev address (workers_dev is on in the config). Once both domains work, set workers_dev to false in apps/landing/wrangler.jsonc and deploy again if you want one address only.

  6. Look at both addresses in a private window. Both should show the page, an address that isn't there should show the 404 page with a 404 status, and /api/health should be a 404.

Nothing here has been run against a real account: wrangler dev serves the files, the config is read by Wrangler, and the custom domains on a bare domain are unconfirmed. The page says "Early days, built for one household" in words; when that stops being true, change it with the FAQ and the plan.

Check the deployed site ​

This asks your own deployed address a few questions as someone who is not signed in, and says whether the answers are safe. It sends plain GET requests (eight), with no cookie, no token and no password, and it never follows a redirect.

  1. From the repository root, run it with your own address in place of demo.example.com (https only; http://localhost works for a local wrangler dev):

    sh
    npm run security:check -- https://demo.example.com
  2. Read the lines it prints: one per check, then a result line. PASS means it saw the answer and it was right. FAIL means it saw a wrong answer: stop and fix that before anyone relies on the site. UNSEEN means it could not see the answer, so it proves nothing about that point. The exit code is 0 unless a check failed (1), or the address was wrong (2).

What you should see on a demo behind Access (the normal case after step 10):

  • ✅ PASS on the three GET /api/... lines: Access sends a stranger to its login and no data comes back.
  • UNSEEN on the rest: the Worker's health answer and headers, /api/dev/*, the X-Now refusal and the cross-origin rule. Access answers every request first, so the Worker never gets to speak. This is expected, not a fault.
  • ✅ The last line reads RESULT: PASS, BUT 12 CHECKS COULD NOT BE SEEN (3 passed): nothing is wrong, and nothing more is proved.

What you should see when the Worker answers for itself (a local wrangler dev, or a deploy where Access is off or the Worker's own address is open): RESULT: PASS (15 of 15 checks), every line PASS, including the 404 for /api/dev/*. (A Worker run with the local wrangler.jsonc allows the clock override and the stub login, so it fails the X-Now line and shows UNSEEN for /api/dev/*, on purpose: that file is never for a deployment.)

Any FAIL line says in words what it saw. It never prints a response body, so even a failing run leaks no household data.

What it can and cannot prove ​

  • Can: that a stranger gets Access's login (or a plain 401/403), never JSON data, on three data addresses; that the Worker, when it does answer, sends the security headers (HSTS of a year or more with includeSubDomains, Cache-Control: no-store, default-src 'none' and frame-ancestors 'none', X-Frame-Options: DENY, nosniff, no-referrer, a closed Permissions-Policy), refuses X-Now, and sets no Access-Control-Allow-Origin of * or of the caller.

  • Cannot: anything that needs a login. It never signs in, so it can't see what Access's policy lets a person do, who is allowed in, whether MFA is on, what a Member can read, or the Worker's headers behind Access. Those are proved by the Worker's tests (headers, /api/dev/* as a 404, X-Now refused) or live in Cloudflare (the policy).

  • Cannot: show that the page is the code you built, that the database holds only fictional data, or that the Worker's own address is switched off. It checks one address, the one you give it.

  • Add --strict to count UNSEEN as a failure (exit 1). Use it against a local run or an open Worker address, where everything should be visible; behind Access it always fails, by design.

  • Checked here (not on a real Access application): the 15 of 15 above is a real run of the generated demo config under a local wrangler dev (no Cloudflare account involved).

  • A redirect counts as the Access login when it goes to any *.cloudflareaccess.com address (it is a smoke check: it doesn't know which team is yours) or to Access's own path on the site; a 401 or 403 HTML page counts only with Access's markers in it. A 2xx page never counts, even one that mentions Access.

  • Anything the server says is cleaned before it is printed (odd characters become ?), so a hostile answer can't repaint your terminal. Access-Control-Allow-Credentials is not checked.

HSTS and the edge. The Worker sends max-age=63072000; includeSubDomains. If the Cloudflare zone has its own edge HSTS switched on, the edge's value may replace the Worker's, and the check will show what a browser really gets. includeSubDomains is effectively one-way once browsers have seen it: use it only on a host whose subdomains are all yours, never on a parent domain others share (an apex, for example).

Unconfirmed: a bare /api (no slash): the Worker's app answers it in tests, but with run_worker_first set to ["/api/*"] production routing may never send it to the Worker. The check doesn't ask for it. And the output above for a real Access-protected deployment is what the check does with the answers Cloudflare Access is documented to give (a redirect to its login, or its login or denial page); this repository's tests use made-up copies of those answers, and the check has not been run against a real Access application.

Custom domain (optional) ​

CUSTOM_DOMAIN serves the Worker on your own hostname as well, for example app.example.com. The generator writes it into the config as a custom domain route ({ "pattern": "<host>", "custom_domain": true }, in either mode), so a deploy keeps it. Without CUSTOM_DOMAIN the generated file has no routes at all, byte for byte as before.

What the generator accepts: a lowercase hostname of at least three parts (app.example.com, not example.com). The three-part rule is only a typo guard: it catches a bare domain typed by mistake, and it does not know which names are a zone's apex (example.co.uk passes). Labels are 1 to 63 letters, digits and hyphens (no hyphen at either end), 253 characters at most, and the last part isn't all digits (that would be an IP address). Punycode hosts (xn-- names, which are plain ASCII) are accepted. It refuses a scheme, path, port, wildcard, underscore, trailing dot, spaces, capitals, and any workers.dev address (that is the Worker's own address, not a custom domain). Set but empty is refused like the other settings.

Before the deploy that adds the domain, make sure Access covers it. Otherwise the app's static files (no household data; the API still answers 401 without a valid Access token) are public on the new address.

  • The one-click Protect this Worker behind Access from step 10, with All traffic, creates an Access application for the Worker itself. Cloudflare's documentation says that covers the Worker's routes, custom domains, workers.dev address and previews. Previews only is described as covering preview addresses only: switch it to All traffic first (Workers & Pages, the Worker, the Access tab).
  • Use one Access application for every address. The Worker accepts exactly one POLICY_AUD, and each Access application has its own audience tag. A separate hostname-based application for the custom domain would, as we understand Cloudflare's rules, take precedence on that host (most specific rule first) and carry a different tag, so the Worker would probably refuse every login there with a 401 (not confirmed). If your protection is a hostname-based application, add the custom hostname to that same application instead (Zero Trust, Access controls, Applications, the application, Edit, its hostnames).
  • The domain's DNS zone must already be on the same Cloudflare account, and the hostname must not already have a CNAME record (Cloudflare refuses to create a custom domain over one). Cloudflare creates the DNS record and the certificate itself.

Then, from apps/worker, generate again with the real audience tag and the domain, and deploy:

sh
D1_DATABASE_ID=<database_id> TEAM_DOMAIN=https://<team>.cloudflareaccess.com POLICY_AUD=<aud tag> \
  CUSTOM_DOMAIN=app.example.com \
  npm run config:generate -w @home-budget/worker -- --mode demo
npx wrangler deploy -c wrangler.generated.jsonc

Keep CUSTOM_DOMAIN in every later generate, or the config has no route again. Finally, open https://app.example.com in a private window. ✅ Access asks you to sign in first, then the dashboard shows the household. ✅ Before signing in, no page or file is served: Access answers first. If you see the app without being asked to sign in, Access does not cover the domain, and the app's static files are public on that address until you fix it. Delete the custom domain under the Worker's Settings, Domains & Routes (and/or add the host to the same Access application) right away. Generating and deploying again without CUSTOM_DOMAIN may not remove it (see below).

Not confirmed (the Cloudflare documentation was searched, not tried on an account):

  • Whether a domain added by hand in the dashboard survives a wrangler deploy that doesn't list it. That is why the generator puts it in the config. After a deploy, check the Worker's Settings, Domains & Routes.
  • Whether removing CUSTOM_DOMAIN and deploying again removes the domain from Cloudflare. Check the same page.
  • That the Worker-level Access application covers a custom domain in practice. The private-window check above is the test: do it right after the deploy.
  • That Cloudflare applies the most specific Access rule first, so a separate hostname-based application on the custom host would win there, and that every login on that host would then be refused with a 401 (different audience tag).
  • That Previews only leaves the production workers.dev address open (the documentation describes it as covering previews only; not tried on an account).
  • The exact dashboard path to edit a hostname-based application's hostnames; the page that describes it could not be read from this environment.

Add the SimpleFIN encryption key (SETTINGS_KEY) ​

Settings has a SimpleFIN page where the admin pastes a setup token. The Worker keeps the connection it gets from that token encrypted in the database, with one key: the Worker secret SETTINGS_KEY. Until the key is there, the page says so and refuses to save (and does not use up the token). The key is not a setting in the generated config: that file never has it, nothing prints it, and no route or log shows it. Do this once per deployment, in apps/worker, after step 7 (a secret needs the Worker to exist):

  1. Make a key: 32 random bytes in base64. It prints one line:

    sh
    openssl rand -base64 32
  2. Keep a copy somewhere safe before you go on, such as the household password manager, named for the deployment (for example "home-budget demo SETTINGS_KEY"). A Worker secret can't be read back from Cloudflare, so that copy is the only one. Keep it out of the repository, chats, tickets and pull requests. The nightly backups contain the sealed connection, and it opens only with this same SETTINGS_KEY, so keep SETTINGS_KEY safe next to the backup key.

  3. Give it to the Worker. The command asks you to paste the value and shows nothing as you do:

    sh
    npx wrangler secret put SETTINGS_KEY -c wrangler.generated.jsonc
  4. Check. npx wrangler secret list -c wrangler.generated.jsonc names SETTINGS_KEY (it never shows a value). ✅ Open Settings as the admin: there is no "The encryption key isn't set up" notice, and Connect works.

If the key is lost or replaced. A connection is sealed with the key that was in place when it was saved, and nothing re-encrypts it later (the key is only used when a connection is saved or read). With another key, or none, Settings says "The saved connection can't be read". The fix is the same for a lost key and for a rotation:

  1. Put the new key in place (steps 1 to 3). Keep its copy.
  2. In SimpleFIN Bridge, disable the old token and make a new setup token. A setup token works once and the old one was used, so the saved connection can't be rebuilt from anything the app holds.
  3. Paste the new token in Settings. Saving seals the new connection with the new key: that is the re-encryption. (A connection that still opens is never replaced by pasting: the app says "Disconnect first" and does not use the token. One that can't be opened is replaced, which is why this step works.)

To remove a connection without replacing it, use Disconnect in Settings; it works without the key.

Running it locally. Put a throwaway key in apps/worker/.dev.vars (git-ignored) as SETTINGS_KEY=<value>, never the real one. The tests use made-up keys of their own and never touch a network.

What is checked, and what isn't ​

  • Checked by tests: every refusal above; neither AUTH_MODE nor NOW_OVERRIDE can appear in a generated file; the fixed parts (assets, migrations folder, compatibility date and flags, the DB and BACKUPS bindings) match wrangler.jsonc; the Cron Trigger is in both modes' generated files and not in wrangler.jsonc; no secret is in a generated file; and a Worker with only the generated variables answers /api/dev/* with 404 (signed in or not) and refuses an X-Now header; every /api/* answer (errors included) has the security headers; a thrown database error is a plain 500.
  • Checked by the deployed-site check (above), from outside: that a stranger gets no data. The Worker's own headers and its dev-route 404 are seen only where Access is not in front.
  • Checked by tests, SimpleFIN: the generator never reads, writes or prints SETTINGS_KEY even when it is set in the environment; a missing or unusable key makes Settings refuse to save before the token is sent anywhere.
  • Not checked: that the secrets were really put on the Worker (only a person can see that), the Access policy itself (who may sign in, MFA) lives in Cloudflare, and the commands above were checked against wrangler --help, not run against an account in this repository's tests. The backup bucket and key steps (3 and 5) are the same: the bucket and secret commands come from wrangler --help, that a secret can be set before a Worker's first deploy is unconfirmed, that the hourly trigger fires on a real account has not been seen, and the restore drill that proves a backup can be read back has not been run on a real account (runbook).