In middleware.js nextUrl.locale is always default for client-side routing if skipMiddlewareUrlNormalize is true #53646
Labels
bug
Issue was opened via the bug report template.
locked
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64 Binaries: Node: 18.16.0 npm: 9.5.1 Yarn: 1.22.17 pnpm: 8.1.0 Relevant Packages: next: 13.4.13-canary.17 eslint-config-next: 13.4.12 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
Internationalization (i18n), Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/matthewcc/middlware-test
To Reproduce
Clone the attached repo, or
skipMiddlewareUrlNormalize: true
to next.config.jsAfter cloning the attached repo or following the steps above, when doing client-side routing (NextLink or browser buttons) the value logged out for
req.nextUrl.locale
is always the default (in this case, "en-US").This is using the classic Next.js setup, I do not know if the behavior is the same for app router or not.
Describe the Bug
If
skipMiddlewareUrlNormalize: true
is in next.config.js, then during client-side routing middleware.js'sreq.nextUrl.locale
is always the default value even if the page is on another locale,The string in
req.nextUrl.pathname
does contain the correct locale during client side routing, ifskipMiddlewareUrlNormalize
is set to true.Expected Behavior
req.nextUrl.locale
in middleware.js should always be accurate.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Vercel
The text was updated successfully, but these errors were encountered: