I'm trying to set up a Laravel API but somehow every time I try to use get I get the following error: Session store not set on request.
It works when I place it out side of the (api) middleware but in that case no authentication would be needed. With post it works perfectly but somehow when I use get I keep getting the error.
This what I have in my routes/api.php:
Route::middleware('auth:api')->group(function () {
Route::get('/test', function (Request $request) {
return 'test';
});
});
PHP version: 7.2.9
Laravel version: 5.6.17
Homestead version: 6.3.0
This is specificly in the auth:api middleware which makes it different from
Use the web middleware if you need session state, CSRF protection, and more...
Route::group(['middleware' => ['web']], function () {
// your routes here
});
I found that I have to include StartSession in $middlewareGroups in my App\\Kernel.php solved my problem
'api' => [
\Illuminate\Session\Middleware\StartSession::class,
'throttle:60,1',
'bindings',
],
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.