Laravel has middleware group called web that protects your routes. it's inside the web.php
file.
you can see routes middleware in the app/Providers/RouteServiceProvider.php
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
web middleware group add lots of middleware to your project such as VerifyCsrfToken
you could see list of them in `app/Http/Kernel.php'
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
as you may know, Laravel has another middleware and route folder called api, that doesn't have any CSRF protection.
you can declare your route that doesn't need CSRF protection (I mean API of your application) to route/api.php
By declaring that kind of routes in route/api.php
file you can easily make the request with Postman/Insomnia like app.
{{ csrf_token() }}
` and CTRL + F5 – Aleksej_Shherbak Mar 06 '19 at 10:40