Skip to content

Let Cloudflare Access callbacks reach the network - #799

Merged
BattermanZ merged 2 commits into
BatterWorks:developmentfrom
jonocairns:fix/cloudflare-access-navigation
Nov 24, 2026
Merged

BattermanZ merged 2 commits into
BatterWorks:developmentfrom
jonocairns:fix/cloudflare-access-navigation

Conversation

@jonocairns

@jonocairns jonocairns commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #798.

Exclude /cdn-cgi/ from the service worker's navigation fallback so Cloudflare Access can handle the sign-in return. Add the same prefix to the server fallback and extend its reserved-path test with the reported callback.

Interface change

  • Producer · The Vite-generated service worker and the HTTP fallback in src/handlers/spa.rs.
  • Behavior change · A navigation under /cdn-cgi/ reaches the network. If it reaches Hatchdoor's fallback, the server returns a bare 404.
  • Consumers · Browsers with the installed worker and Cloudflare Access on the same hostname.
  • Compatibility and rollout · The normal service worker update activates this behavior. Returning to the previous build restores its previous navigation fallback.

Verification

  • just check passed in full mode, including the reserved-path and parity tests.

  • A local Chromium check with the generated worker confirmed a normal navigation used the cached shell and /cdn-cgi/access/authorized reached a fixture server.

  • Reviewed the HTTP API reference and updated it to describe the reserved prefix.

  • The patched worker has yet to be tested against a live Cloudflare Access sign-in.

@BattermanZ

BattermanZ commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: Finish and merge this PR, which fixes #798: the service worker sent the Cloudflare Access sign-in return (/cdn-cgi/access/authorized) to Hatchdoor's cached app instead of the network.

Current behavior:
The diff adds /cdn-cgi/ to the service worker's navigateFallbackDenylist and to the server's SPA_RESERVED_PREFIXES, extends a_reserved_prefix_gets_a_bare_404 with the reported callback path, adds a changelog entry, and updates the HTTP API reference and the module map. The cause it targets was reproduced in triage on #798. On development at 6830beb, a browser controlled by the installed worker that navigates to /cdn-cgi/access/authorized gets the app from the worker (fromServiceWorker: true, status 200).

Checked in triage on the PR head (8af02d3, based on current development): the four handlers::spa tests pass, the parity test included. The built sw.js denylist ends in /^\/cdn-cgi\//. In headless Chrome controlled by that worker, an unknown address (/some/unknown/page) still comes from the worker (status 200), while /cdn-cgi/access/authorized?token=x goes to the network and gets the server's bare 404. The diff does what it claims.

Gaps:

  • The PR body says Refs #798, so merging would leave the issue open.
  • The changelog entry quotes “Page Not Found” with curly quotes. The repo's prose uses straight quotes.
  • Nobody has tested the patched worker against a live Cloudflare Access sign-in, and neither the reporter nor triage can do that here. The browser criterion below is the acceptance bar, rerun on the final PR head.

Desired behavior:
A navigation to any path under /cdn-cgi/ reaches the network whether or not a service worker controls the page. Without Cloudflare in front, the server answers it with a bare 404, like the other reserved prefixes. Nothing else about the worker or the fallback changes.

Key interfaces:

  • navigateFallbackDenylist and SPA_RESERVED_PREFIXES: as the diff has them. The parity test reserved_prefixes_match_the_service_worker_denylist keeps them equal.
  • The PR's description: Closes #798, so the merge workflow closes the issue.

Acceptance criteria:

  • The built sw.js navigation route's denylist excludes paths starting with /cdn-cgi/.
  • A browser already controlled by the service worker that navigates to /cdn-cgi/access/authorized?... gets a response that did not come from the service worker (response.fromServiceWorker() is false in Playwright), while an unknown address such as /some/unknown/page still comes from the worker.
  • Without Cloudflare in front, GET /cdn-cgi/anything on the backend answers a bare 404, not the app.
  • reserved_prefixes_match_the_service_worker_denylist passes with /cdn-cgi/ on both sides.
  • The PR body says Closes #798.
  • The changelog entry uses straight quotes and stays one line under ## Unreleased / Fixed, ending in [#798].
  • The HTTP API reference and module-map wording still read true against the diff (just docs-freshness, then the ack).
  • just check passes on the PR head after review.
  • The PR is merged with ship-pr, as a merge commit, with the reporter's commit and authorship kept.

Out of scope:

@BattermanZ BattermanZ added bug Something isn't working ready-for-agent Implementation-ready for an engineering agent labels Nov 24, 2026
…module map

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013rPDLhETpjZUDsjdKyaDu5
@BattermanZ

Copy link
Copy Markdown
Member

Your PR has been merged, thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-for-agent Implementation-ready for an engineering agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants