Day 97 of 98 · Saturday · Learning

The dark preview - host-check middleware for zorc-home and 1413designer (fa72c94)Hands-on

A Cloudflare Pages project answers on several hostnames; Access guards only the one you configured. Seventeen lines of middleware make every other hostname return 404, and on 10-10 two more sites got them.

Catch-up progress
97/98
Why this matters to you

On 10-1 the Scott Memo security pass found 86 old preview deployments serving meeting content without login. On 10-10 the same hole was found on zorc-home and 1413designer: the default *.pages.dev domain and every hash and branch preview bypassed Access. PDB had closed this in August as CG-3.

Every Pages deploy is reachable at the project's default domain (project.pages.dev), at a per-deploy hash subdomain, at a branch alias, and at any custom domain you attach. Cloudflare Access policies are attached to hostnames, so a policy on 1413designer.zorc.app says nothing about abc123.1413designer.pages.dev. The content is identical on all of them.

A Pages Function in functions/_middleware.js runs before every request. The fix reads the Host header, compares it to a Set of allowed hostnames, and for anything else returns 404 with Cache-Control: no-store (so the edge never caches the refusal into a stale allow) and X-Robots-Tag: noindex (so a search engine that already found the hash URL drops it). Allowed hosts fall through with context.next().

Commit fa72c94 adds this file to interior-designer (1413designer.zorc.app) and the archived zorc-home (zorc.app, www.zorc.app). It mirrors PDB/output/functions/_middleware.js, the CG-3 rule. The pattern generalizes: any project with Access on a custom domain needs the same file, or the custom domain is a front door with the side doors open.

Worked example

Read the file, then test both doors from the terminal.

git -C /Users/tom/Claude/JARBUS show fa72c94 --stat --format=
git -C /Users/tom/Claude/JARBUS show fa72c94 | grep '^+' | grep -v '^+++' | head -17
curl -sI https://1413designer.zorc.app/ | head -3
# the project's *.pages.dev URL is in the Cloudflare dashboard, Workers & Pages > the project
curl -sI https://<project>.pages.dev/ | head -3
head -5 /Users/tom/Claude/PDB/output/functions/_middleware.js
▶ Do it now
  1. Run the two curl checks and write down both status codes. 302 and 404 is the correct pair.
  2. List your Pages projects in the Cloudflare dashboard and note which have Access on a custom domain. Each of those needs a _middleware.js; say which are missing.
  3. Add the two *.pages.dev hostnames the 10-9 audit named to Access, then tell Claude to re-test (the open SYSTEM AUDIT thread on the Desk).

Gotchas

Go deeper: PDB/output/functions/_middleware.js - CG-3 · Cloudflare Pages Functions middleware
One-card takeaway

Access guards a hostname, not a project; make every hostname you did not configure go dark.