<Link as={...}> causes full refresh if as
parameter is a URL that can be rewritten
#22788
Labels
bug
Issue was opened via the bug report template.
please add a complete reproduction
The issue lacks information for further investigation
Stale
What version of Next.js are you using?
10.0.7
What version of Node.js are you using?
14.10.1
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying your application?
next start
Describe the Bug
Following the advice in #11625, it doesn't work if the
as={...}
parameter uses a dynamic route.Expected Behavior
A full page load should not occur. The URL should change but the user should not be navigated away from the page.
To Reproduce
In
next.config.js
:Then, create a link of the form:
This is triggered in
next-server/lib/router/router.ts
, underif (process.env.__NEXT_HAS_REWRITES && asPath.startsWith('/')) {
:If a rewrite is matched, it will throw away the passed in URL and replace it with the rewrite result. This will then cause a full page navigation which does not occur if
as
was not set to a URL that is subject to rewrite.The text was updated successfully, but these errors were encountered: