AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next/Link Prefetches Across Routers In Mixed App/Pages Apps Causing 404S And Wasted RSC Requests

In mixed App Router and Pages Router applications, Pages Router links to App Router routes trigger erroneous `_next/data` prefetch requests that return 404, and App Router links to Pages Router routes send RSC prefetch requests that receive HTML documents instead of Flight data.

highConfidence 85%Next.jsAffected V16.3.6Affected V16.4.0-Canary.51

Origin Analysis

The Pages Router `prefetch()` method lacks an early return after the client router filter (`_bfl`) matches a cross-router transition, causing it to continue issuing `_next/data` requests. The App Router `Link` component does not distinguish Pages Router targets and sends RSC prefetch requests indiscriminately.
1. Build and start a Next.js app with one App Router page (`app/dashboard`) and Pages Router routes (`pages/about.js`, `pages/[[...slug]].js`). 2. Open a Pages route (e.g., `/about`) with Network tab, hover the link to `/dashboard`; observe 404 for `/_next/data/<buildId>/dashboard.json?slug=dashboard`. 3. Open the App route `/dashboard`, hover link to `/about`; observe a prefetch request `/about?_rsc=...` returning HTML instead of Flight data.

Fixing Code Block

Edge Case Audit

This fix only addresses Part A (Pages Router to App Router). Part B (App Router to Pages Router) still requires a similar guard in the App Router Link component to avoid RSC prefetch requests to Pages routes. Without Part B fix, users will still experience wasted HTML downloads. Rollback: remove the added `return` statement and restore the original comment to revert to previous behavior. Ensure no side effects from skipped prefetch in rare cases where `_bfl` might match but the navigation is not actually hard (e.g., custom client router filters). Test thoroughly in mixed apps with custom routing logic.

Ecosystem Topology