Skip to content

fix(vercel): fall back to request query when ISR header lacks the route param - #4599

Merged
pi0 merged 1 commit into
mainfrom
ai/triage/vercel-isr-query-fallback
Sep 13, 2026
Merged

pi0 merged 1 commit into
mainfrom
ai/triage/vercel-isr-query-fallback

Conversation

@pi0x

@pi0x pi0x commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

AI-generated PR. This change was prepared autonomously by an AI triage agent and has
not yet been reviewed by a human. Review the diff and the reasoning carefully before merging.

On Vercel, an ISR route is served by rewriting /schedule to /schedule-isr?__isr_route=/schedule, and the function has to put the original URL back. The value is written into two places: the x-now-route-matches header and the rewritten request URL. isrRouteRewrite only looked at the request URL when the header was absent entirely, so a header that arrives without __isr_route shadowed the query string that still had the right value. When restoration fails the app renders its 404 for the internal -isr path, and Vercel stores 404s in the ISR cache.

This makes the query string a fallback rather than an either/or. Nothing changes when the header carries the param, and the header-less path is untouched.

x-now-route-matches is undocumented and has changed shape before (#3539, #3595), which is why relying on it alone keeps biting.

Two unit tests in test/unit/vercel-isr.test.ts cover a header with only positional capture groups, with and without extra query params. Both fail on main and pass here; the rest of test/unit and test/presets/vercel.test.ts are unchanged.

This is part 2 of the three fixes proposed in #4446. Part 1 there — responding 503 instead of rendering a 404 when the URL cannot be recovered from any carrier — is a behaviour decision and is deliberately not in this PR.

Part of #4446

🤖 Generated with AI assistant

…te param

`x-now-route-matches` was the only carrier consulted whenever the header was
present, so a header without `__isr_route` skipped the query string that
carries the same value.
@pi0x
pi0x requested a review from pi0 as a code owner September 7, 2026 22:43
@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nitro.build Ready Ready Preview Sep 7, 2026 10:43pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 8cd2d287-b64e-4baa-a6f4-326b3a289465

📥 Commits

Reviewing files that changed from the base of the PR and between fc9e575 and b9f4a54.

📒 Files selected for processing (2)
  • src/presets/vercel/runtime/isr.ts
  • test/unit/vercel-isr.test.ts

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

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4599

commit: b9f4a54

@pi0
pi0 merged commit 31d9520 into main Sep 13, 2026
14 checks passed
@pi0
pi0 deleted the ai/triage/vercel-isr-query-fallback branch September 13, 2026 13:26
pi0x pushed a commit that referenced this pull request Oct 15, 2026
Also backports the ISR URL restoration runtime changes from #4409 and #4599.
@pi0x pi0x removed the v3 label Nov 10, 2026

This branch was successfully deployed

1 active deployment
Preview — b9f4a545 Deployed Sep 7, 2026 by vercel[bot]
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.

2 participants