In Laravel 5 this has chagned a bit. Now you can simply add the routes you want to exclude from csrftoken verification, in $except
array of the class
'VerifyCsrfToken' (appHttpMiddlewareVerifyCsrfToken.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
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
array looks like:
protected $except = ['users/valid'];
3. If you want to exclude all routes under main route (users in this case)
Your $except
array looks like:
protected $except = ['users/*'];
see: http://laravel.com/docs/master/routing#csrf-excluding-uris
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…