This is a Next.js project to demonstrate a bug with dynamic routes.
Important
The issue is now fixed in Next.js 15.3.1-canary.2
Under certain conditions, for a page with dynamic route an incorrect params are passed to the page
The error is reproducing for me when the following conditions are met:
- the page in question has a dynamic route
- the parent route of the dynamic route has PPR (Partial Prerendering) enabled
- a middleware is used to rewrite an original URL to patch a route (prepend a locale in my case)
- the project is deployed on Vercel
Important
Note #1: The issue is not reproducible locally.
Important
Note #2: The parameters are passed correctly when navigating to the page from another route. The issue reproduces only when the page is loaded directly, or by refreshing the page.
I have a deployed version of the project on Vercel, where you can see the issue in action.
-
Go to the deployed site
-
Click the
Go to the test page
link- the page has correct params (OK)
-
Refresh the page
- the page has incorrect params, first segment of
rest
is missing and is incorrectly recognized aslocale
(BUG)
- the page has incorrect params, first segment of
-
Go to the test page directly
- the page has incorrect params, first segment of
rest
is missing and is incorrectly recognized aslocale
(BUG)
- the page has incorrect params, first segment of