mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #504] [MERGED] fix: preserve query params on middleware rewrite in App Router #626
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#626
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/504
Author: @NathanDrake2406
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/middleware-rewrite-query-params📝 Commits (2)
b6646e9fix: preserve query params on middleware rewrite in App Router4e5c987test: update entry-templates snapshot📊 Changes
4 files changed (+27 additions, -0 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+4 -0)📝
tests/__snapshots__/entry-templates.test.ts.snap(+4 -0)📝
tests/app-router.test.ts(+10 -0)📝
tests/fixtures/app-basic/middleware.ts(+9 -0)📄 Description
Summary
pathnamewas extracted,searchwas discardedsearchParamspage props,useSearchParams(), navigation context, ISR cache keys) saw the original request's query string instead of the rewrite destination'sserver/middleware.ts:515(pathname + search)Fix
One line in
app-rsc-entry.ts: after extractingrewriteParsed.pathname, also seturl.search = rewriteParsed.search. Sinceurlis a mutableURLobject referenced by ~30 downstream call sites, this propagates automatically with zero additional changes.Test plan
/middleware-rewrite-query) that rewrites to/search-query?searchParams=from-rewrite&extra=injected"from-rewrite"appears in the rendered HTML🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.