Under https://laravel.com/docs/8.x/sanctum#spa-configuration
You did see (scroll down a little) "Sanctum Middleware".
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
401 Unauthorized trying to set up session auth with Laravel 8 and Sanctum.
I've tried every guide out there and saw all stack overflow solutions on this but haven't found a way to get the authentication to persist. I added the SANCTUM_STATEFUL_DOMAINS and SESSION_DOMAIN environment variables but still get the 401. I added the front-end call to get the CSRF-TOKEN cookie before my login call or any of the other calls.
Running out of ideas here. Anyone else with this issue?
Please or to participate in this conversation.