Skip to content

Commit

Permalink
Added support for query params on not found pages (#43836)
Browse files Browse the repository at this point in the history
Previously, query parameters were not available on 404 pages because
calling the router methods would change the pathname in the browser.
This change adds support for the query to update for those pages without
updating the path to include the basePath.

This additionally narrows some Typescript types that were previous set
to `any` which highlighted some type errors that were corrected.

Fixes: #35990

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
wyattjoh and ijjk committed Dec 13, 2022
1 parent f012eab commit cba7070
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 100 deletions.
5 changes: 0 additions & 5 deletions packages/next/client/index.tsx
Expand Up @@ -116,11 +116,6 @@ class Container extends React.Component<{
// - if rewrites in next.config.js match (may have rewrite params)
if (
router.isSsr &&
// We don't update for 404 requests as this can modify
// the asPath unexpectedly e.g. adding basePath when
// it wasn't originally present
initialData.page !== '/404' &&
initialData.page !== '/_error' &&
(initialData.isFallback ||
(initialData.nextExport &&
(isDynamicRoute(router.pathname) ||
Expand Down

0 comments on commit cba7070

Please sign in to comment.