keep language prefix when doing client-side refresh (#31686)
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,11 @@ export default function ClientSideRefresh() {
|
||||
useSWR(
|
||||
router.asPath,
|
||||
() => {
|
||||
router.replace(router.asPath, undefined, { scroll: false })
|
||||
// Remember, in NextJS, the `router.locale` is never including the
|
||||
// `router.asPath`. So we have to make sure it's always there
|
||||
// otherwise, after this hook runs, you lose that `/en` prefix
|
||||
// in the URL on the address bar.
|
||||
router.replace(`/${router.locale}${router.asPath}`, undefined, { scroll: false })
|
||||
},
|
||||
{
|
||||
// Implied here is that `revalidateOnFocus: true` which the default
|
||||
|
||||
Reference in New Issue
Block a user