'What guard should I use in Spatie permission when I'm using sanctum for my APIs?
I'm currently using the Spatie permission package, but I'm a bit confused what guard should I use since I'm using sanctum to authenticate the users. Should I use web? or api? or sanctum?
Solution 1:[1]
you can use the api guard if you have configured the api guard with sanctum driver in auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'admins',
],
'api' => [
'driver' => 'sanctum',
'provider' => 'users',
]
],
and in api.php you can group them with
Route::group(['middleware' => ['auth:api']], function () {
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ahsan Habib Abir |
