N
Nuxt2y ago
Gendarme

Redirect on initial load; conflicts with hydration

Greetings. I am wondering about the implementation of a rather simple "pattern" that is common but somehow I alone seem to be struggling with. I wish to redirect logged in users from the index page to /home (which is common on the web). What I am trying to do is to—in the middleware—poll the backend to see if I am logged in and navigateTo("/home") if true. The problem is that this breaks with SSR, since I would be redirecting during hydration. Is my approach stupid? Is the redirect perhaps supposed to be initiated from the backend... somehow? Is it possible to somehow "await" hydration and redirect afterwards? After extensive searches I have only found one Github issue with the same problem but without a solution: https://github.com/nuxt/nuxt/issues/15136
GitHub
navigateTo causes hydration errors from route middleware (client on...
Environment Operating System: Linux Node Version: v16.14.2 Nuxt Version: 3.0.0-rc.11 Nitro Version: 0.5.4 Package Manager: [email protected] Builder: vite User Config: - Runtime Modules: - Build Modules: ...
1 Reply
Gendarme
GendarmeOP2y ago
Bump
Want results from more Discord servers?
Add your server