vercel / vercel/next.js

Error Mismatch when using `notFound()` inside proxy.

Open
#86,609 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Error Overlay
Dominant language
JavaScript
Stars
142k
Forks
32.5k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/madebyfabian/nextjs-error-mismatch-reprod

To Reproduce
  1. Start the application in development
  2. Visit localhost:3000
Current vs. Expected behavior

Current:

Browser Error shows "Next.js navigation API is not allowed to be used in Pages Router." even though we are only using app router in this reproduction.
Image

Console error is correct:

⨯ Error: Next.js navigation API is not allowed to be used in Proxy.
    at proxy (proxy.ts:5:10)
  3 |
  4 | export async function proxy(request: NextRequest) {
> 5 |   notFound()
    |           ^
  6 | }
  7 | {
  digest: 'NEXT_HTTP_ERROR_FALLBACK;404'
}

Expected: The error shown in the browser should be correct and the same shown as in the console.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.17.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.17.1
Relevant Packages:
  next: 16.0.5 // Latest available version is detected (16.0.5).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: N/A
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Error Overlay

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

next dev (local)

Additional context

Found the two files where these are defined:
Client: https://github.com/vercel/next.js/blob/canary/packages/next/src/client/index.tsx#L933
Proxy: https://github.com/vercel/next.js/blob/canary/packages/next/src/build/templates/middleware.ts#L45

And the test
https://github.com/vercel/next.js/blob/canary/test/development/app-dir/server-navigation-error/server-navigation-error.test.ts

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/next/src/client/index.tsx around line 933 and packages/next/src/build/templates/middleware.ts around line 45 to trace how the browser and proxy errors are selected. Run test/development/app-dir/server-navigation-error/server-navigation-error.test.ts and reproduce the linked app with next dev. Done means the browser overlay reports the same correct Proxy error as the console.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.