cloudflare/vinext

`usePathname` returns internal rewrite path instead of canonical URL

已關閉

#1,348 建立於 2026年5月20日

 (1 則留言) (0 個反應) (0 位負責人)TypeScript (383 個分叉)github user discovery
adapter-api-e2ehelp wanted

倉庫指標

星標
 (8,624 顆星)
PR 合併指標
 (平均合併 1天 1小時) (30 天內合併 462 個 PR)

描述

This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-20).

Problem

When middleware rewrites /rewritten-use-pathname to /hooks/use-pathname, usePathname() should return the external/canonical URL (/rewritten-use-pathname) that the user sees in the address bar. vinext returns the internal route path (/hooks/use-pathname).

Expected: "/rewritten-use-pathname"
Received: "/hooks/use-pathname"

Estimated Impact

~1 test failure.

Affected Test Suites

  • test/e2e/app-dir/hooks/hooks.test.ts (1 failure)

Recommendation

  1. Reproduce first in vinext's own test suite. Add a test with a middleware rewrite and a component that calls usePathname(). Assert it returns the external URL, not the internal rewrite target. Confirm it fails.

  2. Preserve the original request path in navigation context. The setNavigationContext() call should use the original req.url (external/canonical path) rather than the post-rewrite path. The internal rewrite target is used for route matching but should not be exposed to usePathname().

  3. Check both entries/app-rsc-entry.ts and server/dev-server.ts. The navigation context should carry the original pathname in both dev and production.

貢獻者指南