Hi. Can you post some code that we can have a look at? I think it will help us to further understand what you are trying to do.
Sanctum SPA + api routes authentication does not work
Hi everyone,
I'm trying to build an SPA frontend with a laravel 8 backend using Sanctum for authentication.
I've been doing all the configuration following the official documentation.
I can log myself (using Fortify), the authentication using auth:sanctum work in the routes/web.php file, but how can I make it work on routes/api.php ?
I've tried using auth:sanctum or auth:api but I've always got an unauthorized response.
The only way to make it work (for now) is to change the middleware from api to web in the RouteServiceProvider
Did I miss something ?
Thanks
Yeah the logout function is handled with fortify, you will need to make a new route for logout and in that Route simply delete the user token
$request->user()->currentAccessToken()->delete();
Please or to participate in this conversation.