You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the preview URL bar change the URL from https://lllgcy-3000.preview.csb.app/ to https://lllgcy-3000.preview.csb.app/de-de/some/.
Watch the console output, or the render output - a double render occurs, first with route.query === {slug: "some"} and on the second render with route.query === {}.
Describe the Bug
When using the new middleware with dynamic routes and a config with a basePath other than "/" and trailingSlash option set to true all dynamic pages render twice, with some delay between the renders, but on the second render the router.query object is empty.
This is true regardless of whether a useRouter hook or the withRouter HOC is used. Interestingly enough the rest of the router object looks very similar on the second render so asPath, basePath, pathname and route are preserved but query is not.
The bug goes away when removing/renaming the middleware.
The bug goes away when setting trailingSlash to false.
The bug goes away when setting the basePath:"/" or removing the option entirely
The bug does not happen on non-dynamic routes.
There is a closed issue that might be related to this, but the linked PR does not fix this issue.
Expected Behavior
I would not expect a double render to occur.
And in case there is a technical reason to re-render I would expect the second render to preserve the router.query object.
In our project we use the basePath for i18n naming conventions, we can't disable the trailingSlash option, we need dynamic routes for our product catalogue and we need middleware for multiple things so we can not work around this problem easily and so we can't migrate to Next 13.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered:
This ensures we don't apply the trailing slash redirect for `_next/data`
requests as it can cause props to fail to resolve on client transition.
This also fixes `missing` fields not being applied correctly for
`headers` and `redirects` as the field wasn't being passed through.
## Bug
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Closes: #45398Fixes: #45393
x-ref: #45340
Verify canary release
Provide environment information
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
https://codesandbox.io/p/sandbox/adoring-diffie-lllgcy?selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A20%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A20%7D%5D&file=%2Fnext.config.js
To Reproduce
https://lllgcy-3000.preview.csb.app/
tohttps://lllgcy-3000.preview.csb.app/de-de/some/
.route.query === {slug: "some"}
and on the second render withroute.query === {}
.Describe the Bug
When using the new middleware with dynamic routes and a config with a
basePath
other than"/"
andtrailingSlash
option set totrue
all dynamic pages render twice, with some delay between the renders, but on the second render therouter.query
object is empty.This is true regardless of whether a
useRouter
hook or thewithRouter
HOC is used. Interestingly enough the rest of therouter
object looks very similar on the second render soasPath
,basePath
,pathname
androute
are preserved butquery
is not.trailingSlash
tofalse
.basePath:"/"
or removing the option entirelyThere is a closed issue that might be related to this, but the linked PR does not fix this issue.
Expected Behavior
I would not expect a double render to occur.
And in case there is a technical reason to re-render I would expect the second render to preserve the
router.query
object.In our project we use the basePath for i18n naming conventions, we can't disable the
trailingSlash
option, we need dynamic routes for our product catalogue and we need middleware for multiple things so we can not work around this problem easily and so we can't migrate to Next 13.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: