Fix for api not being to see session data
so there was an error when trying to use services for API controllers that was happening because the api middleware didn't pass the same info as web middleware, resulting in session info not being passed to controllers used in the api after a bit of reading discovered necessary middleware could be added to api routing so session data is available in in api routing whew
This commit is contained in:
parent
166e19a656
commit
65854e3dbd
2 changed files with 5 additions and 5 deletions
|
@ -42,6 +42,11 @@ class Kernel extends HttpKernel
|
|||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
//added middleware so api has access to session data
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\API\AuthAPIController;
|
||||
|
||||
|
@ -16,7 +15,3 @@ use App\Http\Controllers\API\AuthAPIController;
|
|||
*/
|
||||
|
||||
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
||||
|
||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue