Even more weird... If I comment out the SESSION_DOMAIN and SANCTUM_STATEFUL_DOMAINS in .env then my session cookie values match, but once I hit a protected route I still get a 401 response with 'message: "Unauthenticated."'
How do I get past No Session error in authentication process with Laravel 9/Angular 13 SPA?
I have my Angular 13 SPA authenticating to Laravel 9 (Sanctum). I'm able to get the CSRF cookie and perform the auth step, which is successful, but when I attempt to hit any other protected API endpoint I get a 'No Session' error. I've spent days going over all of the similar questions and I can't seem to track down a fix.
I have been able to determine that the session cookie I'm seeing on the Angular side does not match the session cookie on the server (Laravel) side of things, which I'm assuming is the issue. I'm just not sure what else to check.
I'm currently proxying /sanctum and /api through Angular so they both answer on localhost:4200.
I've tried several configs for my SESSION_DOMAIN and SANCTUM_STATEFUL_DOMAINS values. All seem to work until I try and hit a protected route:
SESSION_DOMAIN=[assigned alias].ngrok.io
SANCTUM_STATEFUL_DOMAINS=[assigned alias].ngrok.io
SESSION_DOMAIN=.tunnelto.dev
SANCTUM_STATEFUL_DOMAINS=[alias].tunnelto.dev
SESSION_DOMAIN=.dev.local
SANCTUM_STATEFUL_DOMAINS=dev.local:4200
SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost:4200
Thanks in advance!
Please or to participate in this conversation.