platforms icon indicating copy to clipboard operation
platforms copied to clipboard

Router.push using the shallow option causes hard redirect

Open alexbrazier opened this issue 2 years ago • 0 comments

When using a setup with the _sites/[site] structure using router.push or router.rewrite with shallow: true causes a hard redirect, using window.location.href.

e.g.

router.push({ query: { s: ‘test’ }}, undefined, { shallow: true})

causes the full page to be hard refreshed instead of updating the search query without reloading.

I’m using { shallow: false, scroll: false } as a workaround, but it’s still not taking advantage of the shallow update.

Error

So far I'm managed to trace the issue to this function crashing

https://github.com/vercel/next.js/blob/93678b569bb46df9fad39f9db2b18797872b7c15/packages/next/shared/lib/router/router.ts#L1266

where inside getRouteInfo, fetchComponent crashes with Error: Failed to load script: /_next/static/chunks/pages/index.js when the file that it should be loading is _next/static/chunks/pages/_sites/[site].js

alexbrazier avatar Apr 19 '22 19:04 alexbrazier