Question about fetching auth user during SSR

commented 7 months ago

I found few similar questions/issues but I'm not sure that any of that is the answer to my problem.
For example this one:

So, I'm building a web app using nuxt.js with SSR enabled and I'm using auth-module for JWT auth with my Lumen backend.

I have many auth protected pages (auth middleware from auth-module added in the component as middleware: 'auth').
The problem is when the user initially comes to some protected pages - he is redirected to the login page.

I understand that that problem is because package only set user state after fetching the user from backend and that will not occur during SSR.

Is there a way to execute fetching user for every page protected with auth middleware (on Server Side)?

It's a big problem if I, for example, send email to the user with the link to the account settings and he clicks on it and be redirected to the login page but he is logged in. Or if the user bookmarked some protected links.

So, is there a way to fetchUser during SSR? Or can I edit middleware so we can assume that user is logged in if he has _token in cookies?

commented 6 months ago

Actullay I have the same issue.

Question โ€ข Unresolved
#c276 - Created 7 months ago