In Laravel 5, How to disable VerifycsrfToken middleware for specific route?
In Laravel 5 this has changed a bit. Now you can simply add the routes you want to exclude from csrftoken verification, in $except an array of the class 'VerifyCsrfToken' (\app\Http\Middleware\VerifyCsrfToken.php):
class VerifyCsrfToken extends BaseVerifier { protected $except = [ // Place your URIs here ]; }
Examples:
1. If you are using a route group:
Route::group(array('prefix' => 'api/v2'), function() { Route::post('users/valid','UsersController@valid'); });
Your $except
the array looks like:
protected $except = ['api/v2/users/valid'];
2. If you are using a simple route
Route::post('users/valid','UsersController@valid');
Your $except
the array looks like:
protected $except = ['users/valid'];
3. If you want to exclude all routes under the main route (users in this case)
Your $except
the array looks like:
protected $except = ['users/*'];
see: http://laravel.com/docs/master/routing#csrf-excluding-uris