Daily synthetic check from the host
The shape in one sentence: a systemd user timer runs a 100-line Node script once a day that GETs each app's /health and POSTs its passkey login-begin endpoint, and raises a desktop notification when the rpId in the response is not the host the app is served from.
Why /health is not enough
A WebAuthn credential is bound to the relying party ID. When the page's host stops matching the configured RP_ID, the browser refuses both navigator.credentials.get() and .create() with SecurityError: The relying party ID is not a registrable domain suffix of, nor equal to the current domain. The server never sees a failing request, so logs, /health and uptime checks stay green.
Measured cost (2026-06-12 → 2026-09): renaming the account's workers.dev subdomain left one app's RP_ID on the old name. A family could not log in for up to 82 days; a second app was broken for about 85 days and was only found by accident during unrelated work. Both would have been reported the next morning by the check below.
Deliverables
-
~/.config/app-check/{app-check.mjs,apps.json}installed (0700directory) -
node ~/.config/app-check/app-check.mjsprintsokfor every app - The failure path has been seen once (point an entry at a local fake that returns another
rpId) - Every Cron-driven push between your apps has a
pipelinesentry, tried once with--date=on a day known to have failed and once on a quiet day - If the host runs
cloudflare-d1-keyless-host-backup:apps.jsonhasbackups, and its failure path was seen once (pointlastRunat a copy whoseatis 10 days old) -
app-check.timerenabled and one run under systemd is green (pipelines need the unit'sEnvironment=PATH=…, see the unit file)
Install
SKILL=<the directory of this SKILL.md> # Claude Code personal scope: ~/.claude/skills/cloudflare-workers-host-synthetic-check
install -d -m 700 ~/.config/app-check
install -m 644 $SKILL/scripts/app-check.mjs ~/.config/app-check/
$EDITOR ~/.config/app-check/apps.json
node ~/.config/app-check/app-check.mjs
install -d ~/.config/systemd/user
install -m 644 $SKILL/systemd/app-check.{service,timer} ~/.config/systemd/user/
# the unit names a mise-installed node; point it at the node you just ran
NODE=$(node -p process.execPath)
sed -i -e "s|%h/.local/share/mise/installs/node/lts/bin/node|$NODE|" \
-e "s|%h/.local/share/mise/installs/node/lts/bin|$(dirname "$NODE")|" ~/.config/systemd/user/app-check.service
systemctl --user daemon-reload && systemctl --user enable --now app-check.timer
systemctl --user start app-check.service && journalctl --user -u app-check.service -n 10 -o cat
apps.json:
{
"apps": [
{ "app": "myapp", "origin": "https://myapp.example.workers.dev", "health": "/health", "passkeyBegin": "/api/auth/login/begin" },
{ "app": "oauth-app", "origin": "https://other.example.workers.dev", "health": "/health" }
]
}
passkeyBegin is whichever unauthenticated route returns PublicKeyCredentialRequestOptions (/login/begin, /login/options, …). The script POSTs {} and looks for rpId anywhere in the JSON, so both { rpId } and { options: { rpId } } work. Leave it out for apps without passkeys, for routes that only answer GET, and for apps whose options omit rpId (the browser then uses the current host, so there is nothing stale to catch).
Pipelines: did yesterday's push arrive?
A Cron Trigger that POSTs to a sibling app is invisible from outside: the sender logs a status nobody reads, the receiver sees nothing, and unit tests replace fetch. Measured: a nightly digest "went live" and never arrived once in 16 days (Cloudflare error 1042 — cloudflare-workers-pat-bearer-auth ≥ 0.3.0 has the cause). The assertion that catches every variant of that failure is about data, not logs:
if the sender had activity yesterday, the receiver has a row for yesterday created after the day closed.
{
"apps": [ … ],
"pipelines": [
{
"name": "quiz-app -> diary daily digest",
"utcOffsetHours": 9,
"sender": { "cwd": "~/src/quiz/apps/web", "database": "quiz-db",
"activitySql": "SELECT COUNT(*) AS n FROM answer WHERE answered_at >= :start AND answered_at < :end" },
"receiver": { "cwd": "~/src/diary/apps/web", "database": "diary-db",
"arrivedSql": "SELECT COUNT(*) AS n FROM post p JOIN post_tags pt ON pt.post_id = p.id JOIN tag t ON t.id = pt.tag_id WHERE t.norm = 'quiz-app' AND p.first_day = :date AND p.created_at >= :end" }
}
]
}
:start/:endare the epoch-ms bounds of yesterday atutcOffsetHours,:dateis'YYYY-MM-DD'. Each SQL returns one row with a numeric columnn.activitySqlmust mirror the sender's own "is there anything to send" rule, or a quiet day reads as a failure.arrivedSqlmust requirecreated_at >= :end. A row for that day that a human wrote during the day is not the Cron's. Two such rows were once taken as proof that the push worked; theircreated_atwas 17:30 and 23:56, the Cron runs at 00:15.- No activity →
ok … no activity on the sender. Activity and nothing arrived →FAIL+ notification.node app-check.mjs --date=2026-09-15judges a past day (use it once on a day you know failed, and once on a quiet day). - Pipelines run only on a full run (
app-check.mjswith no app names). - Cost: two
wrangler d1 execute --remoteSELECTs a day. They are ordinary queries, not exports, so they do not block the database.
Backups: is the weekly export fresh?
cloudflare-d1-keyless-host-backup notifies once, when a run fails at 04:40 on a Sunday — the sleeping-machine notification of Trap 4. Measured on kokemusu: its export failed with Authentication error [code: 10000] on 2026-10-04, 10-11 and 10-18, and four weeks passed without a new dump before anyone noticed. Judged here every morning, the notice repeats until a run succeeds:
{ "backups": { "lastRun": "~/backups/d1/last-run.json", "maxAgeDays": 8 }, "apps": [ … ] }
FAILwhenlast-run.jsonis missing or unreadable, when itsatis older thanmaxAgeDays, or when any app's last result isok: false. The timer is weekly; 8 days leaves one for a machine that was off on Sunday (Persistent=trueruns it at the next login).- Full runs only, like pipelines. No Cloudflare call: it reads one local file.
Traps
- The rpId rule is "equal or registrable suffix", not "equal".
app.example.comserved withrpId: "example.com"is valid; the script acceptshost === rpId || host.endsWith("." + rpId). It does not consult the public-suffix list, sorpId: "workers.dev"would pass here while a browser rejects it. Nobody configures that by accident; the failure this exists for is a stale full hostname. - Send
Origin. Apps that requireOrigin === ORIGINon non-GET/api/*answer 403 to a barecurl -X POST. The script sendsorigin: <origin>. - One probe a day stays far below an auth rate limit. Do not turn this into a minute-level uptime monitor: the login-begin route is exactly the one that is rate limited per IP, and a challenge-issuing endpoint is not a health endpoint.
- Schedule it for the day. The alert is
notify-send; a 04:00 notification on a sleeping machine is read by nobody.Persistent=truecovers days the machine was off. For alerts when nobody is logged in, putAPP_CHECK_DISCORD_WEBHOOK=<url>in~/.config/app-check/env(chmod 600; the unit reads it withEnvironmentFile=, notEnvironment=, because a webhook URL is a credential and the unit file is 0644) and runloginctl enable-linger $USER. The systemd user unit traps (minimalPATH, linger) are the same as incloudflare-d1-keyless-host-backup. - Add the app on the day it gets its first passkey, not later. The check is only as complete as
apps.json. - The first
wranglercall after the OAuth token expired can fail with 7403, and with--jsonthe reason lands on stdout. A daily timer meets an expired access token every morning; wrangler (3.114 measured, 2026-09-27) refreshes it, rewrites~/.config/.wrangler/config/default.toml, and the very next API call can still answer7403 "The given account is not valid or is not authorized to access this service"— the call after that succeeds. And because--jsonreports errors as JSON on stdout, a script that quotes stderr sees onlyexited 1:. The script retries the count once after 5 s (not after a timeout) and quoteserror.text+notesfrom stdout. Between 2026-09-22 and 09-29 this combination silently left five of seven mornings unjudged while the very push it watches was failing.
What this does not see
- Why a push failed. A pipeline check says "nothing arrived", a day late. The reason (400 after a contract change, 404 from error 1042, 401 from a wrong secret) is only in the sender's log, so the sender should log the response body on non-2xx, and ideally report it somewhere a human looks (
cloudflare-cron-to-discord). Pin the contract with a generated schema (cloudflare-workers-pat-bearer-auth). - Whether a passkey ceremony completes. That needs a browser with a virtual authenticator (
cloudflare-workers-e2e-playwright) and belongs in e2e, not here.
When you change something account-wide
Before renaming a subdomain, moving to a custom domain, or changing an OAuth callback host: grep -rn "<old-host>" ~/src/*/ across every repo, not just the one you are in. RP_ID, ORIGIN, OAuth callbacks, firewall allowlists and notification links all carry the host name, and a passkey app cannot change RP_ID without re-registering every user (the forced-change runbook is in cloudflare-workers-passkey-auth).