Two routes being resolved after using navigateTo, even with 'replace: true' option #16657
Unanswered
AloisSeckar
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In my application I have a link in template like that:
The referenced method does following - puts url param into store (
useQueryXmlis auseStatewrapper), soZadostPreviewpage can read it and fetch the actual data, and then performs redirect to desired locationI think I cannot just use
NuxtLinkfor that becauseurlFormulareis pretty nasty and long string (it is being passed as it is to back-end 3rd party content management system, that returns the actual data) so I don't want to pass it as a dynamic route param. (Maybe this is wrong approach and I should reconsider it?)The problem with my solution is, that it doesn't work. When I am watching the routing either inside
useRouter().beforeEachor inside globaldefineNuxtRouteMiddleware, I see the method is being called two times.First redirection goes correctly from current
/zadost/searchto/zadost/preview, but right after that there is another call/zadost/searchto/zadost/search. And page content remains the same. It only "works" when I click the link another time time. Then the redirect goes/zadost/searchto/zadost/previewand then/zadost/previewto/zadost/previewand the contents change to what I expected to see.I run my project with
ssr: falseoption, so all the navigation should be client-side.I thought passing
{replace: true}options object intonavigateTofunction would prevent exactly such behaviour caused by another route being pushed into router instance instead of being replaced. But either it doesn't work for some syntax reason (passing{external: true/false}the same way worked, I tried that to make sure), or it does something else then I think. I feel like I cannot grasp some basics of how Nuxt works, so maybe the answer is quite simple. Thanks for any clues.Beta Was this translation helpful? Give feedback.
All reactions