DEV Community

Discussion on: Authenticating a React App with Laravel Sanctum - Part 1

Collapse
 
santiagazo profile image
Jay L • Edited

Bob, awesome tut. Thank you so much. I've gone through a few of these laravel/sanctum SPA auth tuts and I keep running into the same problem. I can create the user and log in but anytime I try to hit the middleware route (in this case api/user) I get the response "unauthenticated".

I used your gitLab examples to ensure I had everything working correctly. I've updated the CORS file with allowed_origins => ['*'], I have added to my .env the following two lines:

SESSION_DOMAIN=.lionenergy.com
SANCTUM_STATEFUL_DOMAINS=app.lionenergy.com/

They appear to be working correctly since I can login and get a successful message back. The referee (sanctum_stateful_domains) is exactly what's shown in my chrome developer tools.

I am getting back the x-xsrf-token and it shows that it's getting sent in the request headers to the api/user route too (see image)

Nonetheless, unauthenticated is what I get returned. I'm missing something. Every time I've done this, I've ended up here. Any ideas? Is there something I have wrong with my server-side code?

Collapse
 
wmdarrigo profile image
William D'Arrigo

I have the same issue. Found anything?