carlos / platform Public

demo-referrer-same-origin

Fixes every form POST in demo apps failing in real browsers.

Bug. The demo edge forced Referrer-Policy: no-referrer (f86e9792). Under no-referrer, browsers send Origin: null on a same-origin form POST (Fetch, "append a request Origin header"). The /start starter's same-origin check refuses that, so a visitor's order on a demo got 403 "Something went wrong". Seen 2026-11-11 in headless Chromium 151 on a live dev demo; agents' curl tests set Origin by hand and missed it.

Change. Demo responses now carry Referrer-Policy: same-origin: no referrer to any other origin (what no-referrer bought), and the real Origin on same-origin POSTs. The design spec (4.3) asks only for the strict CSP; plan 2 listed no-referrer among hardening headers without a stated reason, and its own browser witness requires forms to work. The fix applies to existing demos without a rebuild once the edge rolls. The moved notice keeps no-referrer (no forms, GET/HEAD only); console pages are untouched.

Tests.

  • TestDemoReferrerPolicyKeepsFormOrigin states the invariant against a small model of the Fetch and Referrer Policy algorithms: a same-origin POST carries the page's Origin, and nothing to another origin carries a referrer. It checks the model rejects no-referrer, the default and origin-sending policies, then checks what the edge serves on 200/303/403/502 with app overrides.
  • The browser witness's fixture app now refuses Origin: null like the starter. CARLOS_DEMO_BROWSER_TESTS=1 TestDemoBannerBrowser failed at the form step before the fix and passes after it (Chromium 151).
  • go test ./internal/edge/ -run 'TestDemoReferrerPolicyKeepsFormOrigin|TestDemoPolicy|TestDemoHeaderIsolation|TestDemoRedirectPolicy|TestDemoCookieRewrite|TestDemoMoved' passes.

Not reviewed yet. The starter (website repo, src/start/starter/v1) could also accept Origin: null with Sec-Fetch-Site: same-origin as defence in depth; that is a v2 starter, not in this branch.

🤖 Generated with Claude Code

Commits 3
Discussions 0 0 open
Tasks 0/0 done

Discussions

  • No discussions on this branch yet.

Tasks

  • No tasks yet.

Activity