navigateTo() not working on server side
Hello, I am using
navigateTo()
inside useAsyncData()
to perform a redirect on server side but it is not working properly, it only works on client side.
Instead of a redirect on the server, I am getting errors like [nitro] [unhandledRejection] TypeError: $setup.localePath is not a function
but redirect should act before all those variables being called.
Am I missing something?2 Replies
Hi, can you share your code for reproduce error in local?
https://stackblitz.com/edit/github-eedaaw-cayqcb?file=pages%2Findex.vue
As far as I understand, Nuxt is trying to render DOM elements on server side, but, should it try to render them before the useAsyncData loads and the redirection is done?
I do not know if there is another way to do it. In my case the API returns me that a route has changed its name, it gives me the new one and I have to redirect the user to the new page with a 301. Then navigateTo is not working on server side but it works when navigating on the client to the same route.
Solved wrapping everything with v-if useAsyncData var 👍