Skip to content

feat(infra): a Cloudflare Worker that answers short repo URLs with HTTP 200 - #772

Merged
PastaPastaPasta merged 2 commits into
masterfrom
feat/pages-deep-link-200
Nov 27, 2026
Merged

PastaPastaPasta merged 2 commits into
masterfrom
feat/pages-deep-link-200

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Problem

Opened fresh, a repo's short URL returns HTTP 404 before the app loads, for example https://forge.dashhq.org/forge/dash-forge or https://testnet-forge.dashhq.org/pasta-demo/pocket-wallet (checked 2026-11-27). People never notice, because 404.html's shim opens the app. Link previews, crawlers and curl stop at the 404.

The limit: GitHub Pages answers every path it has no file for with 404.html and status 404. It has no rewrites and no way to change the status. Short URLs are dynamic (any owner or repo, created after the build), so they can't be pre-rendered as files either. The 200 has to come from something in front of Pages.

Change

  • infra/pages-deep-links/worker.js, a Cloudflare Worker. It passes every response through unchanged, except a 404 for a path the 404.html shim expands, which it sends with status 200 and the same body and headers.
    • It is generated from the shim's own source (forge-web/lib/deep-link-worker.ts uses SHORT_URL_EXPAND_SOURCE and RESERVED_SEGMENTS), so the two can't disagree.
    • A unit test fails if the committed file drifts from that source.
  • Tests (deep-link-worker.test.ts):
    • short URLs go from 404 to 200 with the body and headers kept;
    • refused paths keep their 404 (/nope, /_next/…, /icons/…, /explore/x, non-numeric issue);
    • other statuses and methods pass through;
    • HEAD also gets 200.
  • Live check: wrangler dev (workerd) in front of the live forge.dashhq.org returned:
    • 200 for /forge/dash-forge and /forge/dash-forge/issues, with a body byte-identical to what Pages sends today;
    • 404 for /nope/x/y/z and a missing /_next/static file;
    • the site's own 200 for / and /explore/.
  • docs/hosting.md §9 gives the deploy steps, as part of the existing "Cloudflare proxy in front of forge.dashhq.org" section, and the check commands.

Not done here (owner-only)

Deploying needs the Cloudflare proxy turned on for forge.dashhq.org (and testnet-forge, which is still DNS-only), plus a Worker route. That is Pasta's call; it also bears on #716 (beacon) and the HTML-rewriting settings in §6. Merging this PR changes nothing that is live.

Compat

Nothing deployed changes. When the Worker is on, the response bodies are the same bytes, so dg verify-app is unaffected by the Worker itself (§6 covers the proxy's own HTML features). The canonical /repo/?… URLs and every existing short link keep working; they just get 200.

🤖 Generated with Claude Code

…TP 200

GitHub Pages answers a repo's short URL with 404.html and status 404, so link previews,
crawlers and curl stop there. Pages can't rewrite or change the status. The Worker passes
every response through, except a 404 for a path the 404.html shim expands, which it sends
with status 200 and the same body and headers. It is generated from the shim's own source.
Deploying it needs the Cloudflare proxy in front of the site (docs/hosting.md section 9).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 03965177-86a0-49e0-8524-b1704668298d
Commits

Reviewing files that changed from the base of the PR and between a15614b and a7ec802.

Files selected for processing: 5

  • docs/hosting.md
  • forge-web/lib/deep-link-worker.test.ts
  • forge-web/lib/deep-link-worker.ts
  • infra/pages-deep-links/README.md
  • infra/pages-deep-links/worker.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

… it changes, route limits, re-paste on change

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit ee15b48 into master Nov 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant