如何在csrf过滤中添加例外
实际上我在控制器上做了这个,它工作正常
$this->beforeFilter( 'auth.user', array( 'except' => array( 'getDownload' ) ) );
但是当我在CSRF上尝试时,异常它给了我这个错误
Illuminate\Session\TokenMismatchException
下面是我的代码
$this->beforeFilter( 'csrf', array( 'on' => 'post', 'exception' => array( 'postDownloadBoot' ) ) );
我想对大多数post方法添加csrf保护,但对某些方法不添加
希望大家能帮忙,谢谢
可以用一种更简单的方法。
$this->beforeFilter('csrf', [ 'on' => 'post', 'except' => 'postDownloadBoot' ]);
也许这可以工作。将此添加到__contruct
函数
$this->beforeFilter('csrf', ['on' => 'post']);
$this->beforeFilter('csrf', ['except' => 'postDownloadBoot']