How to specify auth guard when using multiple guards with Sanctum #preamble Preamble https://laravel.com/docs/sanctum is the go-to solution for token-based API authentication and SPA (Single page application) authentication. It uses an authentication guard when performing the SPA authentication.

If your web app has multiple panels (say, admin, manager, customer, etc)., you'd be using multiple authentication guards.

Assuming that our web app follows this pattern in the API endpoints, we can decide the auth guard dynamically inside the middleware.

//... ]; And with this, your web app should be using the respective auth guard to protect the routes as per the user type.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners