Skip to content

Error Mismatch when using notFound() inside proxy. #86609

@madebyfabian

Description

@madebyfabian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error OverlayRelated to Next.js's error overlay.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions