nextjs - ✅(Solved) Fix Request URLs are normalized in adapter despite __NEXT_NO_MIDDLEWARE_URL_NORMALIZE [1 pull requests, 1 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#87779Fetched 2026-04-08 02:06:09
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2cross-referenced ×1issue_type_added ×1

Fix Action

Fixed

PR fix notes

PR #87776: Respect __NEXT_NO_MIDDLEWARE_URL_NORMALIZE during adapter URL construction

Description (problem / solution / changelog)

For Contributors

Fixing a bug

  • Related issues linked using fixes #number (if applicable)
  • Tests added
  • No new errors introduced

For Maintainers

What?

Fixes an issue where __NEXT_NO_MIDDLEWARE_URL_NORMALIZE was ignored during adapter URL construction, causing request URLs to be normalized even when normalization was explicitly disabled.

Why?

The adapter always normalized the request URL via normalizeRscURL() before checking the flag, making the flag ineffective and causing middleware to observe a mutated URL.

How?

Stop mutating params.request.url and gate normalizeRscURL() at URL construction time so normalization only occurs when allowed.

Fixes #87779

Changed files

  • packages/next/src/server/web/adapter.test.ts (added, +26/-0)
  • packages/next/src/server/web/adapter.ts (modified, +7/-10)

Code Example

Operating System:
  Platform: linux
  Arch: x64
  Version: #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2
  Available memory (MB): 23956
  Available CPU cores: 16
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: 10.26.2
Relevant Packages:
  next: 16.1.1-canary.5 // Latest available version is detected (16.1.1-canary.5).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/fancy-shadow-gy6w5s

To Reproduce

  1. Open the linked CodeSandbox (the dev server already runs with __NEXT_NO_MIDDLEWARE_URL_NORMALIZE=1).
  2. Manually request a .rsc URL in the browser or via curl, for example:
  3. http://localhost:3000/test.rsc
  4. Observe the server logs from proxy.ts.

Current vs. Expected behavior

  • Expected: With __NEXT_NO_MIDDLEWARE_URL_NORMALIZE=1, the proxy/middleware should receive the raw path /test.rsc.
  • Actual: The request is normalized to /test before reaching proxy.ts (visible in logs), even though normalization is disabled. A 404 response is expected, but the URL mutation still occurs.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2
  Available memory (MB): 23956
  Available CPU cores: 16
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: N/A
  pnpm: 10.26.2
Relevant Packages:
  next: 16.1.1-canary.5 // Latest available version is detected (16.1.1-canary.5).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Middleware, Linking and Navigating

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

Vercel (Deployed), next start (local), next build (local), next dev (local), Other (Deployed)

Additional context

The request URL is normalized (specifically, the .rsc suffix is stripped) in the web adapter before middleware or proxy handlers are invoked, which makes the normalization opt-out ineffective. As a result, both App Router and Pages Router flows observe normalized paths even when __NEXT_NO_MIDDLEWARE_URL_NORMALIZE=1, which can be reproduced by manually requesting a .rsc path (404 expected).

extent analysis

TL;DR

Disable URL normalization by modifying the Next.js configuration to handle the .rsc suffix correctly.

Guidance

  • Investigate the next.config.js file to see if there are any existing configurations that might be causing the URL normalization.
  • Check the proxy.ts file to ensure that it is not modifying the URL before logging it.
  • Consider adding a custom middleware to handle the .rsc suffix and prevent normalization.
  • Verify that the __NEXT_NO_MIDDLEWARE_URL_NORMALIZE=1 environment variable is being set correctly and is taking effect.

Example

// next.config.js
module.exports = {
  // ... other configurations ...
  experimental: {
    // Add a custom middleware to handle the .rsc suffix
    middleware: [(req, res, next) => {
      if (req.url.endsWith('.rsc')) {
        // Handle the .rsc suffix here
        next();
      } else {
        next();
      }
    }],
  },
};

Notes

The provided CodeSandbox link and environment information suggest that this issue is specific to the Next.js configuration and the __NEXT_NO_MIDDLEWARE_URL_NORMALIZE=1 environment variable. However, without more information about the proxy.ts file and the custom middleware, it is difficult to provide a more specific solution.

Recommendation

Apply a workaround by adding a custom middleware to handle the .rsc suffix, as shown in the example above. This will allow you to bypass the URL normalization issue until a more permanent solution is found.

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