NuxtN
Nuxt3y ago
bnason

useState and redirection losing value

I'm using useState within my auth plugin and during the SSR, it redirects to the login page if they are not authenticated. It's also capturing the current path and saves it in a useState ref, however, when the redirect happens, it's doing an HTTP redirect, which basically creates a new request to the server which seems to re-call the ssr and that re-runs the plugin but this time it doesn't know about the previous requests path.

Does anyone have any suggestions?
Was this page helpful?