Repository navigation
fix(adapters): scan layouts for islands - #87
Merged
Merged
Conversation
Member
Author
|
(The one failing test is unrelated to this PR.) |
cpojer
approved these changes
Apr 8, 2026
cpojer
enabled auto-merge (squash)
April 8, 2026 00:00
Brooooooklyn
disabled auto-merge
April 8, 2026 03:22
Member
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1afff14aa7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Named island layouts (_layouts/*.island.*) were omitted from the buildStart pre-scan, so island imports declared inside them were missing from the hydration map when virtual:void-islands-client loaded before transforms ran. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cpojer
pushed a commit
that referenced
this pull request
Sep 11, 2026
* feat(dispatch): handle URL rewrites at the edge
Extend the dispatch worker to support rewrite rules (status 200)
alongside existing redirect rules (3xx).
- Refactor applyRedirectRules into applyRoutingRules returning a
discriminated union: redirect (Response) or rewrite (destination)
- Rewrites modify the request pathname and continue through the
normal pipeline (ISR, static assets, worker dispatch)
- Set X-Void-Original-URL header on rewritten requests so the
worker can access the original URL
- Add tests for rewrite matching, splat substitution, and
mixed redirect/rewrite last-match-wins ordering
* docs: add rewrites design doc and update READMEs
- New design doc 0062-rewrites covering motivation, design
decisions, static and middleware rewrites, X-Void-Original-URL
- Update dispatch README to mention rewrites
- Update root README "Where Code for X Lives" table
* test(dispatch): add rewrite integration tests
Test the full dispatch flow for rewrites:
- Rewrite forwards to worker with rewritten pathname
- Splat substitution in rewritten paths
- X-Void-Original-URL header set on rewritten requests
- Query string preserved through rewrite
- Non-matching paths pass through unchanged
- Last-match-wins when redirect and rewrite rules overlap
* feat(dispatch): named path params and query preservation on redirects
Swap the glob-only matcher for a shared compiler in headers.ts that
supports named captures (:name for one segment, :name* for zero-or-more).
Legacy * keeps working as an anonymous :splat catch-all. Destinations
are substituted via :name tokens; redirects.ts uses this for both
redirect and rewrite paths.
applyRoutingRules now returns a discriminated { destination, status }
instead of a pre-built Response, which lets the caller merge the
request's query string into the Location header. Previously we dropped
?utm, auth state, pagination etc. on 3xx responses. Destination query
wins on per-key conflict.
No change to rewrite behavior (it only mutates pathname).
* feat(dispatch,api): fallback rewrites for static deployments
Add a post-lookup rewrite phase that fires only when the static asset
resolver returns null. Source is routing.fallbacks in void.json,
surfaced through the deploy manifest as fallbackRules.
Scope is static/SPA deployments. Worker projects own their own 404
handling and are not intercepted, which avoids per-request re-dispatch
cost and keeps the worker's routing model unambiguous.
Evaluation is single-pass: one fallback match re-resolves the asset
path and serves it (or 404s if the rewritten path also misses).
Redirects in fallbackRules still short-circuit with query preservation.
* docs: rewrites v1.1 revisions and considered-and-rejected
Document the three DX additions landed on this branch (named params,
fallback rewrites, query preservation on redirects) and capture the
two generalizations that were evaluated and declined so they're not
re-litigated later: external rewrite destinations (SSRF surface, egress
accounting, open-proxy posture) and conditional matching on
cookies/headers/query (middleware already covers this, and adding it
to static rules would contaminate the edge cache key).
* fix(dispatch): guard consumed body before rewrite request clone
A disturbed stream makes the Request constructor throw, so POST/PUT
requests whose body was already read failed at the rewrite branch
before reaching the downstream bodyUsed fallback.
* fix(dispatch): forward rewritten URL through ISR worker fetches
ISR miss render and background revalidation were dispatching the
original request, so a /docs → /en/docs rewrite rendered /docs content
but cached it under the /en/docs key (and kept refreshing from /docs).
Hoist the rewritten-request builder so hashed-asset, ISR, and final
dispatch all share it.
* feat(dispatch,api): accept force field and fallbackRules from new framework manifest
Framework's feat/rewrites branch introduces `routing.fallbacks` / rewrites,
emitting richer manifest entries:
- `redirectRules` / `fallbackRules` entries may carry `force?: boolean`.
Dispatch doesn't branch on it — the list identity (pre-asset vs post-asset
phase) already encodes the semantic — but it must be accepted so manifests
parse. Mirrored on `DeployManifest` in @voidcloud/api.
- Add integration coverage for the SPA + user-fallbacks shape the CLI now
emits: synthetic `/*` → `/index.html` catch-all prepended, user rules
appended. Last-match-wins in dispatch lets the more-specific user rule
(e.g. `/docs/*` → `/docs.html`) win when it matches, and the synthetic
catches everything else. Covers static-only fallbackRules, `_redirects`
200-entries via fallbackRules, and `force: true` redirectRules.
* fix(dispatch): address PR review findings for rewrites
- Strip any client-supplied X-Void-Original-URL on ingress so dispatch
is authoritative on CF. Previously the header was only set on the
rewrite path and passed through verbatim otherwise, letting clients
spoof the original URL seen by non-Void user workers.
- Preserve the pre-rewrite pathname for the fallback edge-cache key
when routing.version is absent. Under the previous code the key was
built from the rewritten pathname, so repeat hits to the original
URL never found the cache entry.
- Document why the force field is carried through on redirect/fallback
rules but not branched on — the list identity encodes the phase.
* docs: refresh rewrites design doc for v1.1 implementation
Update Files changed to include the shared pattern compiler in
packages/dispatch/src/headers.ts, the discriminated applyRoutingRules
and mergeQueryIntoLocation helper in redirects.ts, fallbackRules
propagation in packages/api/src/routing.ts, and force-field plumbing
in types.ts. Add an Interaction with header rules subsection — rules
match the post-rewrite pathname. Bump revised date.
* docs(rewrites): consolidate design doc into single coherent spec
Fold v1.1/v1.2 revision sections into the main Design section (this is
all one PR, no shipped v1.0 to revise) and document the newly added
c.rewrite / c.originalUrl / c.isRewritten context helpers alongside
CloudEnv-scoped typing.
* test(dispatch): unit tests for pattern compiler and param substitution
Add direct coverage for compilePattern, matchPatternCaptures, and
substituteParams — previously exercised only transitively via redirect
integration tests. Pins down named captures, middle-splat behavior,
legacy * handling, cache identity, and missing-param substitution.
* refactor(dispatch,api): drop force field from rewrite manifest wire shape
The `force?: boolean` was accepted on `redirectRules` and `fallbackRules`
manifest entries for forward-compat, but dispatch never branched on it —
list identity alone (pre-asset `redirectRules` vs post-asset `fallbackRules`)
determines phase. The framework is dropping `force` from the shipped
manifest in a sibling change, so drop it from the wire type here too.
Updated tests: stripped `force` from fixtures, renamed the
`redirectRules with force: true` describe block to reflect that the phase
is what's under test, and removed the now-obsolete "tolerates force" case.
* docs(rewrites): correct design doc for two-phase manifest and edge/node loop distinction
The Design intro claimed a single `redirectRules` array contains both redirects
and rewrites; in reality the manifest splits into `redirectRules` (pre-asset)
and `fallbackRules` (post-asset, static deployments only). Rewrite the intro
to describe the two-phase model accurately.
Also clarify that the `X-Void-Rewritten` header guard is a framework-runtime
concern for Node/Bun/Deno targets that re-dispatch via `app.fetch` — dispatch
at the edge is single-pass and doesn't need loop prevention. Update the
"files changed" bullets to reflect that `force` is a framework-internal flag
and not a wire field.
* fix(dispatch): skip rewrites whose destination is not path-absolute
Framework validates at build time that rewrite destinations start with `/`,
but a malformed or tampered manifest could still reach the edge. Guard both
rewrite sites (pre-asset `redirectRules` and post-asset `fallbackRules`)
with a defensive `startsWith('/')` check: log and skip the rule on violation
so the request falls through to normal resolution rather than crashing on
`url.pathname = 'https://...'` or producing a bogus URL.
Adds coverage in `fallback-rules.test.ts` for both phases.
* fix(api): harden manifest validation for rewrite wire shape
- Accept status 200 in redirectRules (framework ships force rewrites
from routing.rewrites and _redirects 200! with status: 200).
- Validate fallbackRules symmetric to redirectRules, with status locked
to 200 since fallbacks are rewrites only.
- Reject `?` in rewrite/fallback destinations in both rule branches —
request query is merged separately at dispatch time via
mergeQueryIntoLocation, so an embedded query in the destination
silently breaks merging. Framework already rejects this at build time.
Adds five integration regression tests covering the status-200 accept
path and each new rejection.
* docs(dispatch): list fallback-rules.test.ts in README source layout
The file was added alongside the rewrites feature but wasn't
registered in the README's source-layout block or test list.
* docs(rewrites): align design doc with X-Void-Original-URL signal and CF-dev gap
c.isRewritten() in the framework now reads X-Void-Original-URL instead
of a separate X-Void-Rewritten header, which fixes the CF-prod path
where dispatch rewrites the pathname and sets the former but not the
latter. The framework loop guard is a WeakSet on the in-memory Request
object, not header-based. Update the doc to describe both accurately
and drop the (now removed) X-Void-Rewritten references.
Also note the CF-dev asymmetry: static routing rules are applied by
dispatch in prod, but dispatch doesn't run under `vite dev`, so those
rules are inert locally on the CF target. Parity holds on
node/bun/deno where the rules are compiled into the worker middleware.
* feat(isr,api,dispatch): scope cache keys to rewrite variants + review fixes
ISR variant keying
- Include the `X-Void-Original-URL` value in the ISR cache key so
direct and rewritten requests to the same pathname cache
independently — necessary whenever a user handler branches on
`c.isRewritten()` or `c.originalUrl()`.
- New `encodeIsrVariantToken` / `splitIsrCacheKey` /
`isrCacheVariantPrefix` helpers in `isr-shared`; dispatch + API
revalidation thread the original URL through every cache call
site.
- Path revalidation scans the `<path>#rw=` variant subspace and
purges each variant (KV entry + reconstructed edge URL), so a
single `revalidate({ paths: [destination] })` invalidates all
rewrite sources under that destination.
Review findings
- API validator rejects non-path-absolute destinations on
status-200 `redirectRules` and on every `fallbackRules` entry.
- Dispatch wraps `compilePattern` in a per-rule try/catch so a
malformed manifest pattern (e.g. duplicate `splat`) skips with
a warning instead of 500ing the request.
- Headers compile-cache LRU eviction uses an explicit `done`
check instead of a non-null assertion.
Design doc `0062-rewrites.md` updated for two-phase traversal,
cross-system loop guard, and ISR variant keying. Dispatch README
source layout reflects the shared pattern compiler in `headers.ts`.
* docs(rewrites): drop stale standalone rewrite() mentions
The framework ships only c.rewrite(path); the standalone rewrite(c, path)
export referenced in this doc does not exist. Align the spec with the
shipped API.
* chore(dispatch): clarify rewrite guard intent + add log context
- Comment the path-absolute guard as defense-in-depth: the API rejects
non-absolute destinations at manifest ingress (packages/api/src/routes/
deploy.ts); this guard covers KV mutation / manifest-version skew.
- Include the matched request path in the malformed-rewrite console.warn
calls so production logs are triageable. Rule source isn't in scope at
the log site, so path= is used as the best available locator.
* fix(api): allow '?' in 3xx redirect destinations + 303 test + ISR design-doc note
- deploy.ts no longer rejects '?' in redirectRules destinations when status
is a 3xx; mergeQueryIntoLocation handles the merge. 200 force-rewrites
and fallbackRules still reject '?'.
- Add a 303 redirect case to dispatch redirect tests to lock the contract
end-to-end now that framework + platform both accept 303.
- Clarify in the rewrites design doc that middleware c.rewrite() reuses the
dispatch-assigned ISR slot; only dispatch-phase rewrites contribute to
variant cache keys.
* docs(rewrites): isr-shared README, design doc refinements, dispatch/api README updates
- packages/isr-shared/README.md (new): documents the byte-identical
contract between api (purge) and dispatch (read/write), enumerates
every export, explains key format (#rw= variant suffix, base64url
token), and spells out the rule that any key/URL shape lives here
(not duplicated) and format changes require an
ISR_CACHE_KEY_VERSION bump.
- packages/dispatch/README: split Request Flow into explicit pre-asset
redirectRules (step 4) and post-asset fallbackRules (step 7).
- packages/api/README: point Deploy Flow at manifest wire-shape
validation (deploy.ts:468-532).
- meta/design-docs/0062-rewrites: enumerate status allowlists
(redirectRules [200,301,302,303,307,308], fallbackRules [200]);
correct the middleware X-Void-Original-URL passage (middleware does
set the header; ISR cache isolation is a timing concern, not
header-participation); add CF-dev gap note — no dispatch locally, so
c.originalUrl() returns null for dispatch-side rewrites, while
middleware c.rewrite() still sets the header.
* test(dispatch): X-Void-Original-URL surface, body-consumed rewrite, fallback+ISR pin
- redirectRules rewrite forwards full pre-rewrite URL (including query)
in X-Void-Original-URL on workerRequest.
- body-consumed POST rewrite path: asserts the forwarded request has no
body, content-length/transfer-encoding stripped, X-Void-Original-URL
still set, no throw.
- fallbackRules rewrite (static deployments): pins the current reality
that no worker dispatch happens (asset serve only), so there is no
workerRequest to inspect and ISR is not invoked. Includes an
isrCacheKey pure-function contract test so the #rw= variant shape
stays locked in, with a TODO for the day fallback+ISR actually share
a code path.
* docs(rewrites): ISR variant keying, isr-shared consumers, body-rebuild rationale, 200! example
Credits X-Void-Original-URL as the variant-token source in dispatch README
and links to isr-shared. Marks isr-shared as an internal platform package
with dispatch and api as the only intended consumers. Explains why
content-length is dropped on the body-consumed rebuild paths. Expands the
_redirects example in the design doc to show 200! vs plain 200 so the
two-phase encoding is concrete.
* fix(rewrites): reject // destinations + pin framework wire shape + bump framework
- api/deploy.ts + dispatch/index.ts: reject protocol-relative
destinations (`//host/x`) in redirectRules (status 200) and
fallbackRules. startsWith("/") alone let them through even though
they parse as cross-origin URLs, defeating the defense-in-depth
story dispatch already claims against a malformed manifest. 3xx
redirects still accept external URLs.
- dispatch/test/framework-contract.test.ts: compile-time pin on the
framework wire shape `{source, destination, status}` — re-adding
a `force` field (or otherwise drifting) breaks typecheck on the
platform side.
- meta/design-docs/0062-rewrites.md: new "Framework pin" section
naming the pinned SHA and the cli/types.ts contract boundary.
- isr-shared/README.md: expand the v2 bullet so a future maintainer
doesn't drop the prefix as dead weight — it's what lets pre- and
post-rewrite entries coexist during rollout.
- framework submodule: 1586e50 → 8ba805a (picks up the stale-warning
drop, c.rewrite `//` guard, same-source ordering pin, and the
vestigial-test cleanup).
* refactor(dispatch): drop rewrite-destination re-validation
The framework rejects non-path-absolute / protocol-relative / query-in-
destination rewrites at build time (`packages/void/src/config.ts`), and
the API re-checks them on manifest ingest before writing to KV. Dispatch
used to re-check a third time and `console.warn + fallthrough` on
failure, which is a worse failure mode than surfacing the bad manifest
loudly (silent drop on a corrupted KV entry → weird 404s no one can
trace). Trust the two ingress gates; drop the edge-level guard and the
four defensive tests that pinned it.
* docs(rewrites): flag static-fallback worker-skip and lead with isr-shared rationale
- dispatch/README.md: note that on static deployments a matched
`fallbackRules` entry serves the resolved asset directly without
worker dispatch — so `X-Void-Original-URL` is not set, `c.originalUrl`
is unavailable, and the response is not ISR-cached. This gap is
already pinned by `test/unit/fallback-rules.test.ts`; surface it in
the README so readers see it up front.
- isr-shared/README.md: lead the Purpose section with *why* the
variant-key suffix exists — user code that branches on
`c.isRewritten()` / `c.originalUrl()` needs cache splits per
pre-rewrite URL. The original "producer/consumer drift prevention"
paragraph follows unchanged.
* style: conform rewrite code to Array<T> generics
Matches main's `chore: Change array notation to generics` rule which
landed on platform after feat/rewrites forked. Auto-fixed by oxlint;
affects dispatch + api test helpers and one internal type in dispatch.
* refactor(rewrites): platform review cleanups + bump framework
- dispatch/src/index.ts: extract rebuildRequest(request, url, mutateHeaders)
for the three near-identical header/body rebuilds (ingress X-Void-Original-URL
strip, rewrite URL swap, post-ISR re-dispatch). Drop the unreachable
fallback.type === 'redirect' branch (fallbackRules are API-validated
status-200-only) with a one-line unreachability comment.
- api/src/types.ts: introduce named RedirectRule and HeaderRule interfaces
replacing the two inline object types on DeployManifest; export
MANIFEST_REDIRECT_RULE_STATUSES as a shared const consumed by the ingest
validator.
- api/src/routes/deploy.ts: use the shared status const in place of the
inline allowed-status literal.
- isr-shared: trim public surface from 11 to 6 helpers. normalizeIsrPath,
canonicalIsrPathname, encodeIsrVariantToken, decodeIsrVariantToken,
isrCacheVersionPrefix, and ISR_CACHE_KEY_VERSION are package-internal now;
README updated.
- dispatch/test/unit/framework-contract.test.ts: import RedirectRule from
the framework submodule source (via relative path) and from api, with
structural round-trip + keyof pins on each side. The test is now
load-bearing against framework-side and api-side drift.
- dispatch/test/unit/fallback-rules.test.ts: drop the 80-line ISR-propagation
"negative contract" describe (test-as-doc for an acknowledged gap; the
pure-function half duplicated isr.test.ts).
- dispatch/test/unit/index.test.ts: merge duplicate body-consumed rewrite
tests; add a new rewrite test that exercises the custom-domain KV key
path (domain:<hostname>) by building ROUTING by hand so the slug-vs-domain
branch in dispatch is actually covered.
- meta/design-docs/0062-rewrites.md: reconcile with shipped code. WeakMap
(not WeakSet), CF-dev parity inverted (rules fire locally), client-header
stripping at dispatch ingress, framework-side CF-prod-only header read,
rollback-unsafety for status-200 rules, v2 ISR key-prefix rationale.
Rename Framework pin -> Framework wire contract; drop the stale SHA pin.
- Bump framework submodule to 540d214 (matching framework-side rewrite
cleanups).
* fix(dispatch): type workerFetch param so mock.calls indexing typechecks
CI caught that the custom-domain rewrite test's workerFetch was inferred
with no-arg signature, making tuple-index access through mock.calls fail
tsgo's narrowing. Declaring the param as Request gives the mock the
typed call-tuple the extraction needs.
* refactor: better rror msg
* rename and refactor
* test(deploy): align manifest-shape assertions with source-annotated messages
* refactor(dispatch): rename redirects.ts to routing-rules.ts
The module's exported function is `applyRoutingRules` — the file name
should match. Updates imports, the framework-contract test reference,
the API-side doc comment, the rewrites design doc, and the README.
* refactor(dispatch): extract path-pattern helpers into pattern.ts
`headers.ts` was housing the pattern compiler and captures/substitute
helpers that routing-rules and ISR path matching both reuse. Pulls
`compilePattern`, `matchPattern`, `matchPatternCaptures`,
`substituteParams`, and `CompiledPattern` into a dedicated
`pattern.ts`, leaving `headers.ts` focused on header-rule application.
Splits the tests along the same seam and updates the README source map.
* refactor(api): use Set for MANIFEST_REDIRECT_RULE_STATUSES
Membership-test constant is naturally a Set. Drops the
`ReadonlyArray<number>` cast at the call site in favor of `.has()`, and
documents why the source string is passed through `JSON.stringify`
(safe quoting/escaping of user-supplied content in the error message).
* refactor(api): drop isr-cache re-exports of shared pure helpers
`isr-cache.ts` was re-exporting pure key/URL helpers from
`@voidcloud/isr-shared` as a transitional convenience. Callers now
import those directly, leaving `isr-cache.ts` focused on the API-only
pieces that touch `KVNamespace`.
* fix(dispatch): don't 500 header rules on malformed patterns
matchPattern / matchPatternCaptures now return false / null when the
pattern fails to compile (e.g. duplicate `splat` capture from multiple
legacy `*`). applyRoutingRules already caught and skipped these, but
applyHeaderRules called matchPattern unguarded, so a hand-crafted
manifest reaching the edge could turn normal traffic into 500s.
* fix(dispatch): preserve fragment when merging query into redirect location
mergeQueryIntoLocation now splits off `#fragment` before merging and
re-appends it afterwards. Previously `/new#faq` + `?utm=x` produced
`/new#faq?utm=x`, which browsers treat as fragment text — the query
was effectively lost. Correct form is `/new?utm=x#faq`.
* fix(isr): hash variant token instead of base64-encoding the URL
KV is operator-readable and the prior `btoa(originalUrl)` token let any
operator with list access recover the original URLs — including
sensitive query strings like `?token=…`/`?email=…`. Switch to a
fixed-length FNV-1a 64-bit hex hash so the token is opaque and
length-bounded regardless of input.
splitIsrCacheKey now returns `{ normalizedPath, variantToken }`; the
purger uses `isrEdgeCacheUrlForToken` to rebuild the matching edge
cache URL since the original URL is no longer recoverable.
* fix(api): cap routing rule lists at deploy-ingest validation
Each rule compiles a regex per request in dispatch, so a manifest with
100k entries exhausts CPU on every project request. Cap redirectRules
and fallbackRules at 2000 entries (per list, well above what real
frameworks emit) and reject oversized lists at deploy ingest so dispatch
never sees them.
* fix(isr): cap rewrite-variant entries per (project, deployment, pathname)
Even with the queryAllowlist defaulting to drop every param, a path with
an allowlisted param can still be probed by varying the param value.
The cap is the second line of defense: once the KV slot for a pathname
holds 200 variants, new variants stop being written. The worker still
renders fresh content; we simply refuse to persist it, so KV growth and
revalidation cost stay bounded. Existing variants continue to update so
ISR refresh keeps working.
* fix(dispatch): preserve request.cf when rebuilding the worker request
Plain `new Request(url, { method, headers, body })` drops `cf` (country,
colo, botManagement, tlsClientAuth, …) on the floor. User workers that
read `request.cf` for geolocation, bot scoring, or mTLS info silently
saw an empty object whenever dispatch rebuilt the request (X-Void-Original-URL
strip, post-rewrite re-dispatch, post-ISR fallback). Thread `cf` through
init.cf explicitly. See remix-run/remix#3640 for the same pattern.
* fix(dispatch): key hashed-asset cache on the post-rewrite URL
Hashed assets are cached `immutable` for a year. The cache key must
track the post-rewrite (hash-bearing) URL, not the request URL — a
redirect rule that maps `/logo` to `/assets/logo-<hash>.png` would
otherwise cache content under `/logo`, and a future deploy pointing
`/logo` at a different hash would keep serving the stale entry under
its 1-year immutable Cache-Control.
* fix(isr): default-strip query from rewrite-variant cache key
The variant key on a rewrite was derived from the full original request
URL (with query). Varying any param (`?utm`, `?cb`, `?fbclid`, …) fanned
out cache slots and forced repeated SSR — Brook's DoS scenario in the
PR thread.
Default-strip every query param from the variant URL. Per-pathname
allowlist (manifest field `revalidateQueryAllowlist`, persisted to the
ROUTING entry as `queryAllowlist`) opts specific params back in for
paths where query genuinely affects rendered output (search pages,
paginated lists, etc).
Also splits the rewrite-time `originalUrl` into two values: the
ISR variant key (normalized, security-relevant) and the
X-Void-Original-URL header (full request URL — what user code expects
to see via `c.originalUrl()`).
* fix(dispatch): apply routing.fallbackRules in WfP/framework branch
For static deployments, fallbackRules fire post-asset-miss (line ~533).
For WfP/framework projects (SvelteKit/Nuxt/Astro), the user worker is
the path resolver — its 404 is the analogue of a static-asset miss.
Without this branch, framework users author `routing.fallbacks` (e.g.
SPA shell `/*` → `/index.html`), see it work in vite dev, and watch
it silently 404 in production.
Single-pass: the rewrite target's response is returned as-is, no
further fallbacks even if it also 404s.
* fix(dispatch): apply fallback rules on ISR misses
* fix dispatch fallback ISR cache writes
* fix dispatch legacy multi-splat patterns
* fix: handle fallback rewrite cache variants
* fix: gate void fallback dispatch
* fix(rewrites): address routing review follow-ups
* fix(rewrites): post-review hardening (bump framework)
* Preserve request.cf during ISR background revalidation (F7).
revalidateInBackground was building the re-render request via
`new Request(url, { method, headers })`, dropping the edge-populated
`cf` bag (country, colo, botManagement, tlsClientAuth). The user
worker re-rendered with `cf === undefined` and wrote wrong-geo or
wrong-bot HTML into the ISR cache for the next TTL window. Replaced
with the existing `rebuildRequest` helper which threads `cf` through
every branch, mirroring all other re-dispatch paths in dispatch.
* Flush ISR purge per cursor page in `body.all` revalidation (F11).
runRevalidate previously accumulated all pathnames + variant tuples
across every deployment id and every KV list page, then expanded into
a flat URL array sized
`|hostnames| × |ids| × (2·|paths| + 2·|variants|)`. For high-cardinality
projects (~20k paths × ~50 variants) this exceeded the 128 MB Worker
cap and OOM'd mid-purge, leaving KV partially deleted. Now flushes
`purgeEdgeCache` per cursor page; CF tolerates duplicate purge URLs
so cross-page dedup loss is fine. Aggregate `purged` count preserved
via a project-wide pathname set (bounded ~MBs even at high cardinality).
* Keep literal `:` semantics for non-rewrite pattern matchers (F8).
The new shared `compilePattern` in `dispatch/src/pattern.ts` treats
`:name` as a single-segment named capture. That's intentional for
redirect/rewrite/fallback rules per design-doc 0064, but three other
consumers — `routing.headers`, `routing.revalidate`, and
`routing.revalidateQueryAllowlist` — silently inherited the new
semantics through the shared `matchPattern`. Existing tenant configs
using `:` as a literal URL character (e.g. `/api/v1:health`,
`:batchGet`-style) would silently begin matching unrelated paths.
Added `matchLiteralPattern` (escape regex specials, expand `*` only,
defensive try/catch) and switched the three non-rewrite consumers to
it. The capture-aware compiler stays for routing rules. Renamed the
inline matcher in `api/src/routes/deploy.ts` to match and added a
sync-comment cross-referencing the dispatch version.
Bump framework submodule to 63867e9 — pattern hardening + validator
fixes, c.rewrite fragment strip, behavioral X-Void-Original-URL test.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore: bump framework — guard routing-rule compile errors
Picks up fc089f8: emitApplyRoutingRules now wraps per-rule pattern
compilation in try/catch so a single malformed routing rule (duplicate
named-capture groups) cannot 500 every CF dev request hitting the
middleware. Build-time validator assertUniqueCaptureNames catches the
misconfiguration at config-read for redirects/rewrites/fallbacks.
Mirrors dispatch's existing applyRoutingRules behavior — CF prod was
already safe because dispatch had this try/catch from the start.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(dispatch): preserve request body across worker fallback re-dispatch
When a worker-backed fallbackRule fires on a non-GET request, the inner
re-dispatch lost the body silently. The first `worker.fetch(dispatchReq)`
consumed the body stream; `applyWorkerFallbackRules` then called
`rebuildRequest(dispatchReq, ...)`, which takes the `bodyUsed` branch and
returns a new Request with method/headers but no body and the framing
headers stripped. Any user fallback covering a POST/PUT endpoint
(e.g. `/api/*: /api/handler` BFF pattern) saw an empty payload at the
fallback handler — the request looked syntactically valid, just empty.
Clone `dispatchReq` before the first worker.fetch when both:
- method has a body (not GET/HEAD), and
- routing.fallbackRules has at least one entry.
Pass the clone to applyWorkerFallbackRules so the inner re-dispatch can
re-stream the body. `Request.clone()` tees the underlying stream on CF
Workers — the standard mechanism for replay. Skipped on the common case
(GET, or no fallback rules) so zero overhead.
Regression test: POST + JSON body, fallbackRule covering the URL,
asserts the handler receives the original body verbatim. Test fails
without the fix (handler returns 'not found').
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore: bump framework — fast path & c.rewrite blocklist follow-ups
Picks up abca2ef:
* resolveStaticPageDataBuildOptions now disables the page-data fast
path when routing.rewrites or routing.fallbacks is set, not just
routing.redirects. Without this, static-output projects with
in-config rewrites silently render unrewritten page data on
client-side <Link> navigation.
* c.rewrite asset-extension blocklist filters to extensions NOT used
by registered routes/pages, so c.rewrite('/feed.xml') to a real
feed.xml.ts handler stops falsely throwing VoidAssetRewriteError.
Genuine asset paths (.png, .css, etc.) still produce the helpful
error when no route shadows that extension.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* chore: bump framework to main — feat/rewrites merged
PR #125 (feat: add url rewrites) landed on framework main as squash
9eb1be5, replacing the per-fix snapshot pointer with the merged
single-commit head. All routing-rules / rewrites / fallbacks /
c.rewrite / static-page-data / pattern-compiler work from this
branch is now part of the framework's main history.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: LongYinan <lynweklm@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Brooooooklyn
added a commit
that referenced
this pull request
Nov 24, 2026
…, show the last bypass - waiting_scan copy (API and CLI) says when it waits for a deploy going live or for the project's Zero Trust row, not only for a scan (#75, #86). - The CLI bypass sends the request it saw; the route takes `requestId`, so a bypass that loses to a protect gets 409 `public request closed` with its state instead of "no public request ... run public" (#72). - Bypass refusals keep the API code, status and blockers in `--json` (#93). - GET /projects/:id/zero-trust returns `lastBypass` (reason for deploy and up) and `zero-trust status` prints a "Last bypass" line (§13.3). - `protect` that cancels an open request prints "Public request canceled. <slug> stays protected."; a held `public` prints the CLI request lines and "Check it: void project zero-trust status" (§11.4, §13.3, #80). - A public-only Zero Trust switch with the gate on is refused with 409 `security public gate on` before the existing-projects check (#64). - Copy nits: "finishes" for one going-public project, the requester in the cancel preview, "failing since" from a stored start of the probe failure, bypass during a Zero Trust change says "Try again after it ends", and a passed request drops its held reason (#65, #87, #89, §5.2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce tests that validate the pre-scanning of island imports from both layouts and pages, ensuring correct entries in the manifest.
(The next commit will fix the failing tests)