I figured it out! I had the error as there are 2 missing pieces of middleware on my api route group. I added the following 2 middlewares to the api
middleware group and then added that group to my API routes and it fixed the issue!
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Session\Middleware\StartSession::class,
Can you post the fixed code as a reference to anyone having the same problem ?
Just add the web middleware to your route entry like this:
Route::get('/file', 'FileController@createNewFile')->middleware('web');
This group already contains he middleware needed for persistent sessions in ajax calls
hellfull said:
Can you post the fixed code as a reference to anyone having the same problem ?
Put that 2 lines of code to app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [
// ...
],
'api' => [
\App\Http\Middleware\EncryptCookies::class, // <------- ADD THIS
\Illuminate\Session\Middleware\StartSession::class, // <------ ADD THIS
// ...
],
];
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community