How to turn off CRSF protection for specific route in Laravel?

devquora
devquora

Posted On: Feb 22, 2018

 

To turn off CRSF protection in Laravel add following codes in “app/Http/Middleware/VerifyCsrfToken.php”

 
//add an array of Routes to skip CSRF check
private $exceptUrls = ['controller/route1', 'controller/route2'];
 //modify this function
public function handle($request, Closure $next) {
 //add this condition foreach($this->exceptUrls as $route) {
 if ($request->is($route)) {
  return $next($request);
 }
}
return parent::handle($request, $next);
} 

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Laravel interview questions

    What is Laravel?

    Laravel is a free open source "PHP framework" based on the MVC design pattern. It is created by Taylor Otwell...