nextjs - 💡(How to fix) Fix [Bug] RSC re-fetches permanently stop when <Link> prefetches a proxy-rewritten route that adds hidden search params [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#90658Fetched 2026-04-08 00:19:41
View on GitHub
Comments
3
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
commented ×3labeled ×2issue_type_added ×1

Root Cause

The root condition: RSC re-fetches only work on /test when the page was loaded with at least one search param already in the URL. The moment the URL has no params — either because you loaded that way or navigated there — RSC re-fetches stop entirely.

Code Example

pnpm install
pnpm run deploy

---

export const proxy = (request: NextRequest) => {
    if (request.nextUrl.pathname === '/test') {
        const url = new URL('/dynamicPages/filtered', request.url)
        url.searchParams.set('testParam', 'testValue') // hidden param — key condition
        for (const [key, value] of request.nextUrl.searchParams.entries()) {
            url.searchParams.set(key, value)
        }
        return NextResponse.rewrite(url)
    }
    return NextResponse.next()
}

---

<Link href="/test">Test page</Link>

---

export default async function FilteredPage({ searchParams }: Params) {
    const resolved = await searchParams // accessed — should opt into dynamic rendering
    // renders resolved.page, resolved.filter, resolved.testParam
}

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.22.0
Relevant Packages:
  next: 16.2.0-canary.65 // Latest available version is detected (16.2.0-canary.65).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/VeiaG/nextjs-proxy-rewrite-prefetch-rsc-bug-

To Reproduce

Clone reproduction repo

Important: must be tested with a production build. Does not reproduce in dev mode.

pnpm install
pnpm run deploy

The header has two links:

  • Blue — /test — public URL that is rewritten by the proxy (buggy path)
  • Green — /dynamicPages/filtered — direct URL, no rewrite (works correctly, for comparison)

Confirming the direct route works (baseline)

  1. Click the green /dynamicPages/filtered link
  2. Click + to set page=2 → Server searchParams updates ✅
  3. Click reset → Server searchParams updates back to default ✅
  4. Click + again → updates ✅ — everything works normally

Reproducing the bug on the rewritten route

The root condition: RSC re-fetches only work on /test when the page was loaded with at least one search param already in the URL. The moment the URL has no params — either because you loaded that way or navigated there — RSC re-fetches stop entirely.

Simplest reproduction:

  1. Navigate directly to /test (no params)
  2. Click + or any filter → URL updates but Server searchParams does not change

Illustrated with contrast:

  1. Navigate directly to /test?page=2 (server renders with params)
  2. Click + → page goes to 3, Server searchParams updates ✅ — works because page loaded with params
  3. Click reset → URL becomes /test (no params), Server shows page=1 (default)
  4. Click + → URL becomes /test?page=2 but Server searchParams does not update
  5. Click any filter → Server searchParams does not update

Open the Network tab: no _rsc requests are sent in steps 4–5.

Minimal reproduction code

src/proxy.ts — adds testParam=testValue to every rewrite of /test:

export const proxy = (request: NextRequest) => {
    if (request.nextUrl.pathname === '/test') {
        const url = new URL('/dynamicPages/filtered', request.url)
        url.searchParams.set('testParam', 'testValue') // hidden param — key condition
        for (const [key, value] of request.nextUrl.searchParams.entries()) {
            url.searchParams.set(key, value)
        }
        return NextResponse.rewrite(url)
    }
    return NextResponse.next()
}

src/components/Header.tsx<Link> with default prefetch pointing at the rewrite source:

<Link href="/test">Test page</Link>

src/app/dynamicPages/filtered/page.tsx — server component that reads searchParams:

export default async function FilteredPage({ searchParams }: Params) {
    const resolved = await searchParams // accessed — should opt into dynamic rendering
    // renders resolved.page, resolved.filter, resolved.testParam
}

To toggle the bug:

  • Remove url.searchParams.set('testParam', 'testValue') from proxy → bug disappears
  • Add prefetch={false} to the <Link href="/test"> → bug disappears

Current vs. Expected behavior

Expected behavior

Every navigation that changes search params (including removing them all) should trigger an RSC re-fetch for the server component. The server should receive the current search params and return fresh output.

Actual behavior

When the user navigates back to the rewrite source URL with no visible search params (/test), no RSC request is sent. The router serves the stale prefetch response cached during the initial prefetch of /test. The server component renders with outdated searchParams.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:40 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.22.0
Relevant Packages:
  next: 16.2.0-canary.65 // Latest available version is detected (16.2.0-canary.65).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Middleware, Linking and Navigating

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

Using output:standalone. Reproducible in docker builds & local build

In a production build, when a proxy rewrite adds a hidden/extra search parameter to the internal URL and a <Link> component prefetches the public (pre-rewrite) URL, the server component at the rewrite target stops receiving RSC re-fetch requests once the user navigates back to the URL with no visible search params.

The server-rendered output remains stale — it shows the values from the prefetch response, not the current URL state.

Two conditions required — both must be present

ConditionAloneTogether
<Link href="/test"> with default prefetch✅ works❌ broken
Proxy adds a hidden param to rewrite URL✅ works❌ broken

Removing either condition fixes the bug. The bug only manifests when both are active simultaneously.

Video demonstrating this issue:

https://github.com/user-attachments/assets/9e6eb32d-62c6-42d3-abd6-b72be7ed4ef5

extent analysis

Quick Fix

**Disable the

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Every navigation that changes search params (including removing them all) should trigger an RSC re-fetch for the server component. The server should receive the current search params and return fresh output.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING