-
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
router.query does not contain path parameters if a middleware is used #54077
Comments
+1, facing the same issue even in v13.5.2, have replicated this in a CodeSandbox here : Example . Replicable when The Similar open issues : |
I could fix the problem after reading this doc: I wish that this page was easier to find. |
@mesaquen Can you explain more about what you did? I don't think the above article can solve the issue. Thanks! |
Hi @nhim175 So, in the end of the day, after a few tests, I got rid of the middleware file, migrated the whole project to App Router and replaced |
@mesaquen Thank you so much for clarifying what you did. I'm running into the same issue so I thought it's possible to use middleware. I also got rid of the middleware but still want to understand why it happened.
|
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023 Binaries: Node: 18.17.0 npm: 9.6.7 Yarn: N/A pnpm: N/A Relevant Packages: next: 13.4.16 eslint-config-next: N/A 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)
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/ferenckv/next-router-bug
To Reproduce
Clone the repo
git clone https://github.com/ferenckv/next-router-bug
Go to 13.4.16
cd 13.4.16
Install dependencies
npm install
Run the app in dev mode
npm run dev
Go to http://localhost:3002
Click on
Click Here!!
You should see a text that says
Test: user1
Click on
Action
You should see the url change to
http://localhost:3002/users/user1/test?step=1
Stop the app
Run the app in production mode
npm run start
Repeat steps 5 & 6
Instead of
Test: user1
you only seeTest:
Refresh the page
Now the text is correct:
Test: user1
Repeat steps 5 & 6
Click on
Action
The url changes to
http://localhost:3002/users/[userId]/test?step=1
instead ofhttp://localhost:3002/users/user1/test?step=1
Describe the Bug
Given that these conditions are met:
When you do something like this
Then
router.query
does not contain the values of the path parameters.Expected Behavior
router.query
must contain the values of the path parameters.Which browser are you using? (if relevant)
Chrome 115.0.5790.171
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: