Yes, it is possible to use Laravel Passport for API authentication and sessions for web authentication in the same Laravel application. You can use Laravel's built-in session middleware for web authentication and Passport's middleware for API authentication.
To use sessions for web authentication, you can add the web middleware group to your routes:
Route::group(['middleware' => ['web']], function () {
// web routes here
});
To use Passport for API authentication, you can add the auth:api middleware group to your API routes:
Route::group(['middleware' => ['auth:api']], function () {
// API routes here
});
Make sure to configure Passport properly by running the necessary migrations and setting up the necessary routes and controllers.
Also, keep in mind that using sessions for web authentication may not be suitable for SPA applications, as they typically use token-based authentication. In that case, you may want to consider using Passport for both web and API authentication.