Question about fetching auth user during SSR

mbackonja
3
mbackonja
commented 3 months ago

Hello,
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: https://github.com/nuxt-community/auth-module/issues/53

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?

1
hasanmumin
0
hasanmumin
commented 2 months ago

Actullay I have the same issue.

0
Informations
Question โ€ข Unresolved
#c276 - Created 3 months ago