nextjs - ✅(Solved) Fix Incorrect filesystem routing when %2e present in the URL path [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#86717Fetched 2026-04-08 02:09:37
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
3
Author
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #86733: Fix: Handle encoded dots (%2e) in filesystem routing for static pages

Description (problem / solution / changelog)

What?

Fixes an issue where URLs containing %2e (encoded dot) were failing to resolve to filesystem paths for static pages, resulting in 404 errors.

Why?

The server was treating %2e as a filename character instead of normalizing it to a dot .. This prevented matching against folder names like my.folder when the URL was /my%2efolder.

How?

Added a normalization step in base-server.ts to replace %2e (case-insensitive) with . before route matching occurs.

Fixes #86717

Changed files

  • packages/next/src/server/base-server.ts (modified, +5/-0)
  • test/e2e/app-dir/issue-86717/index.test.ts (added, +41/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:39 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.21.0
  npm: 10.9.4
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: 15.4.4
  react: 19.1.1
  react-dom: 19.1.1
  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/hdodov/test-nextjs/tree/bug-filesystem-routing

To Reproduce

I've put detailed instructions in my reproduction repo's README.

Current vs. Expected behavior

What it boils down to is the normalization of URLs containing "%2e" which decodes to a period ("."). For example, Next will route the following URLs differently:

…which I believe is not the correct behavior.

If I have these two routes in my app:

  • app/api/my-route/route.ts
  • app/api/[...anything]/route.ts

…then the following happens:

  1. http://localhost:3000/api/my-route
    • renders app/api/my-route/route.ts
  2. http://localhost:3000/api/test/%2e%2e/my-route
    • renders app/api/[...anything]/route.ts

On one hand, it makes sense that the [...anything] route is rendered in the second case, since the URL path doesn't literally match api/my-route. But browsers normalize the URLs and Next.js does so as well, since request.nextUrl.pathname is resolved to /api/my-route in both cases.

So it doesn't make sense that nextUrl.pathname is /api/my-route, but the rendered route is not api/my-route/route.ts. Check the README in my reproduction repo for more details.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:39 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.21.0
  npm: 10.9.4
  Yarn: N/A
  pnpm: 10.19.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: 15.4.4
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Dynamic Routes

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

next dev (local)

Additional context

This can also be a security concern, as it opens the door for cache poisoning attacks:

  • I configure my proxy (e.g. Cloudflare) to cache /api/my-route
  • I make a request to /api/test/%2e%2e/my-route
  • Next.js maps this to a completely unexpected route
  • That route returns an HTTP 4XX status (or even 5XX)
  • The proxy caches the 4XX response
  • Regular requests to /api/my-route show the broken cached response

extent analysis

TL;DR

The issue can be addressed by configuring Next.js to handle URL normalization for routes containing "%2e" which decodes to a period (".").

Guidance

  • Review the Next.js documentation for handling URL normalization and routing configuration to ensure that the application is correctly handling URLs with encoded periods.
  • Consider implementing a custom middleware or route handler to normalize URLs before they are processed by Next.js.
  • Verify that the request.nextUrl.pathname is being correctly resolved and used in the routing logic.
  • Test the application with different URL encodings to ensure that the routing behavior is consistent and secure.

Example

No specific code example can be provided without modifying the existing codebase, but reviewing the next.config.js file and the routing configuration in the app/api directory may help identify the issue.

Notes

The provided environment information and package versions may be relevant to the issue, but without further investigation, it is unclear if they are the root cause. Additionally, the security concern mentioned in the issue highlights the importance of correctly handling URL normalization to prevent cache poisoning attacks.

Recommendation

Apply a workaround by implementing a custom middleware or route handler to normalize URLs before they are processed by Next.js, as this will allow for more control over the routing behavior and help prevent potential security issues.

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

nextjs - ✅(Solved) Fix Incorrect filesystem routing when %2e present in the URL path [1 pull requests, 1 participants]