nextjs - 💡(How to fix) Fix `next-router-prefetch` header missing on some prefetch requests [4 comments, 3 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#85836Fetched 2026-04-08 02:13:42
View on GitHub
Comments
4
Participants
3
Timeline
15
Reactions
0
Author
Timeline (top)
commented ×4mentioned ×3subscribed ×3labeled ×2

Code Example

missing: [
        { type: 'header', key: 'next-router-prefetch' },
        { type: 'header', key: 'purpose', value: 'prefetch' },
      ],

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:26 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/salazarm/nextjs-missing-prefetch-header/tree/main/nextjs-missing-prefetch-header

To Reproduce

  1. Build the repo app npm run dev and start it npm run start.

  2. Observe in the network panel that we're prefetching the same url twice, once with the next-router-prefetch header set and once without.

    From the guide here: I'm using:

 missing: [
        { type: 'header', key: 'next-router-prefetch' },
        { type: 'header', key: 'purpose', value: 'prefetch' },
      ],

But since sometimes the prefetch doesn't include next-router-prefetch we end up including the CSP on those and in my case the CSP is 7kb and we make a lot of prefetch requests so it adds up quickly.

Current vs. Expected behavior

  1. I expected all prefetch requests to include the next-router-prefetch header
  2. I expect to only prefetch the 123 route once.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:26 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Not sure, Dynamic Routes

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

next build (local), Vercel (Deployed)

Additional context

No response

extent analysis

TL;DR

  • The issue can be mitigated by ensuring all prefetch requests include the next-router-prefetch header to prevent duplicate prefetching and reduce unnecessary CSP inclusions.

Guidance

  • Review the Next.js configuration to ensure that the next-router-prefetch header is correctly set for all prefetch requests.
  • Verify that the missing configuration in the CSP settings is correctly implemented to include the next-router-prefetch header.
  • Check the network panel to confirm that the next-router-prefetch header is present in all prefetch requests after applying the configuration changes.
  • Consider adding logging or debugging statements to identify cases where the next-router-prefetch header is missing and investigate the root cause.

Example

No specific code snippet can be provided without modifying the original code, but ensuring the next-router-prefetch header is set in the prefetch requests can be achieved by reviewing the next.config.js file and the CSP configuration.

Notes

The provided information suggests that the issue is related to the next-router-prefetch header not being included in some prefetch requests, but the exact cause is unclear. Further investigation into the Next.js configuration and the CSP settings is necessary to determine the root cause.

Recommendation

  • Apply workaround: Ensure all prefetch requests include the next-router-prefetch header to prevent duplicate prefetching and reduce unnecessary CSP inclusions, as this is a more immediate solution to mitigate the issue while the root cause is investigated.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING