laravel4.0指定某些路由不需要验证,在app/filters.php文件里面
Route::filter('csrf', function()
{
$list=['check_asy_pay_res','check_syn_pay_res/service','check_syn_pay_res/mobile'];//白名单
if (Session::token() !== Input::get('_token')&&!in_array(Request::path(),$list))
{
throw new Illuminate\Session\TokenMismatchException;
}
});
laravel5.0 在appHttpKernel.php 的$middleware里面,去掉这句话
'App\Http\Middleware\VerifyCsrfToken',
或者在中间件app/Http/Middleware/TokenMiddleware.php 里面
public function handle($request, Closure $next)
{
// 使用CSRF
//return parent::handle($request, $next);
// 禁用CSRF
return $next($request);
}
或者
public function handle($request, Closure $next)
{
return parent::addCookieToResponse($request, $next($request));
}