Laravel API route requires Session2020-05-27 php laravel
I used Laravel only for API requests. So i have deleted the Session classes from Kernel.php.
My routes are in web.php. Now i need to create web pages. So i moved current routes to api.php, and this occurs error.
Class session.store does not exist
Why api routes tries to use Session? Because api calls don't need Session. How can i switch off session for api routes? Because api calls accepting more than 100 requests per second.
Laravel's default guard is set to
web. When you use only API endpoints, you need to change your
api for example. You can see in
api does not includes session middlewares so they are not used.
If you use the default api driver
token then you need to add a
api_token column to your users table and include this parameter on the request like
Take a look at https://laravel.com/docs/6.x/api-authentication#introduction. Seems that it changed in Laravel 7 but I don't know which version you are using.
- How do I get a YouTube video thumbnail from the YouTube API?
- Reference — What does this symbol mean in PHP?
- Difference between require, include, require_once and include_once?
- Laravel requires the Mcrypt PHP extension
- Laravel 405 error + no api methods in artisan routes:list
- laravel 5.6 session not persisting when view returned
- Laravel API routes authenticated by user session
- Laravel 5: Convert existing web.php to api.php (RESTFUL API)
- Laravel API expired session
- Laravel 5.4 API route