Hello, as I can see in the docs, sanctum can be used to protect web routes because he first attempt to autenticate by session cookie. https://laravel.com/docs/8.x/sanctum#protecting-routes
At now, the api routes works well but the web returns always a redirect 302 to the login route.
I need to protect a route that return an image from the storage, I have tried like this in my routes/web.php
:
Route::get('images/exercise/{imageId}', function (Request $request) {
return Storage::get('demo/450.png');
})->middleware('auth:sanctum')->where(['imageId' => '[1-9][0-9]*']);
Where I'm wrong? Thank you
Essentially I was authenticating without using the Auth facade.. but the session cookie was also created. 🤷♂️
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community