Reputation: 43
I have a server async notify route :
Route::post('notify/payment/{gateway}','Payment@receiveNotify')
How to disable default web middleware ? (session and verifycsrftoken)
Upvotes: 2
Views: 2130
Reputation: 5925
Since Laravel 7.7 you can use method withoutMiddleware
eg:
Route::post('notify/payment/{gateway}','Payment@receiveNotify')->withoutMiddleware(['csrf']);
Upvotes: 0
Reputation: 929
in my case, since I am using API based development, I just commented out this line in app/Http/Kernel.php
// \App\Http\Middleware\VerifyCsrfToken::class,
Upvotes: 0
Reputation: 840
Yes, you can Just remove the 'middleware' => 'web' block entirely and continue like you used to.
But I prefer below option.
Go to your app/providers/RouteServiceProvider.php file and update like below and as per you needs:
For e.g :
public function map(Router $router)
{
$this->mapWebRoutes($router);
$this->mapApiRoutes($router);
}
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
protected function mapApiRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'api',
], function ($router) {
require app_path('Http/routes-api.php');
});
}
Upvotes: 0
Reputation: 3930
It's in the map()
method of your RouteServiceProvider
.
Keep in mind, the web middleware group is automatically applied to your default routes.php file by the RouteServiceProvider.
https://www.laravel.com/docs/5.2/middleware#middleware-groups
Upvotes: 3