-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Middleware rewrites with shallow navigation break query object from Next router #41053
Comments
We're running into what I think might be the same issue, except we don't have middleware doing the rewrites, but we have a rewrites property in our next config instead. The bug occurs when a rewrite happens. We have a multi-locale setup where the url can be in different languages (the Another interesting note: in your repo, if you open the console of the browser as well as the console of the app inside the codesandbox environment, you'll see different things. The browser console will show a filled query path param, the codesandbox console won't. We have the same thing: The nextjs server knows exactly what the query path param is, but when it sends it to the client, it's not there. I checked the props passed the main App component in our One last difference between our app and yours: A hard refresh gives us the correct Summarizing: It seems that any rewrite will result in the query object lacking the path param for dynamic routes (during client side routing in our app). Are you still having this issue, 6 months later? Edit: btw, we're on Next 13.2.1 |
I'm experiencing an empty |
I've worked around this issue using a dynamic path, it's not optimal but it fixes the issue that I was having. Now my routing structure looks like this; Something to note; in the Codesandbox link in the issue above it's using |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Safari Version 16.0 (17614.1.25.9.10, 17614)
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
When using middleware for server side AB tests (rewriting the url) having a shallow navigation to the same dynamic page with a different query causes the NextJS router to no longer return the correct query parameters.
Expected Behavior
I expect the NextJS router to give back the query parameters from the url after making a shallow navigation while using middleware to rewrite the url server side.
Link to reproduction
https://codesandbox.io/s/youthful-antonelli-3ifojo
To Reproduce
Visit the link and use one of the anchor tags to navigate from one dynamic page to another dynamic page. All of these pages are on the same dynamic route:
/[test]/page
. However the middleware will give you an AB test that internally rewrites you to/[test]/new-page
. The A version will give you the title in black and the B version in red. Currently the test is setup to always give you the B version.After navigating the query object that from the NextJS router will return an empty object instead of showing the value from the URL. When changing the cookie manually to "Original" to get the A version of the test the shallow navigation will keep giving the correct value.
This issue appears both on development and production mode.
The text was updated successfully, but these errors were encountered: