1 year ago

How to access auth()->user() that authorizes/authenticates with jwt-auth from different pages of app?

Posted 1 year ago by p0t4t0

I've been at this problem for several hours now and still can't figure it out, hoping to get help on this matter.

The problem: is it possible to have access to auth()->user() across different pages outside of React which has been "set" on a page where my React instance lives and does authentication/authorization?

Currently: I have two routes: /home and /dashboard, /home is your typical Laravel app (blade views, reloads, and all that jazz), /dashboard on the other hand is a single page React app which has routes of its own courtesy of React Router, probably not the best implementation but it does the job.

Expected outcome: to be able to have access to auth()->user() in the /home page (it seems to stop working after I login from the React app on /dashboard and navigate to /home).

Any and all help is appreciated thank you.

Please sign in or create an account to participate in this conversation.