我收到了很多这些错误:
[2015-06-25 18:27:00] production.ERROR: exception 'Illuminate\Session\TokenMismatchException' in /home/xxx/public_html/vendor/compiled.php:2550
Stack trace:
#0 /home/xxx/public_html/app/Http/Middleware/VerifyCsrfToken.php(17): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#1 /home/xxx/public_html/vendor/compiled.php(9197): App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#2 /home/xxx/public_html/vendor/compiled.php(12377): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#3 /home/xxx/public_html/vendor/compiled.php(9197): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#4 /home/xxx/public_html/vendor/compiled.php(11067): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#5 /home/xxx/public_html/vendor/compiled.php(9197): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#6 /home/xxx/public_html/vendor/compiled.php(12079): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#7 /home/xxx/public_html/vendor/compiled.php(9197): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#8 /home/xxx/public_html/vendor/compiled.php(12027): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 /home/xxx/public_html/vendor/compiled.php(9197): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /home/xxx/public_html/vendor/compiled.php(2589): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /home/xxx/public_html/vendor/compiled.php(9197): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /home/xxx/public_html/vendor/platform/installer/src/Middleware/Installer.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /home/xxx/public_html/vendor/compiled.php(9197): Platform\Installer\Middleware\Installer->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /home/xxx/public_html/vendor/compiled.php(9188): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#16 /home/xxx/public_html/vendor/compiled.php(1996): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /home/xxx/public_html/vendor/compiled.php(1983): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#18 /home/xxx/public_html/public/index.php(68): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#19 {main}
我无法找到他们来自哪里,因为该网站拥有大量流量。
我在每页的顶部都有这个:
<meta name="csrf-token" content="{{ csrf_token() }}">
我的所有表格都有:
<input type="hidden" name="_token" value="{{ csrf_token() }}">
我不想像人们在其他帖子上提出建议那样删除CSRF。
您是否知道如何调试此错误以找出错误源自何处?只是寻找有助于发现错误的调试思路。
非常感谢。
答案 0 :(得分:1)
好吧所以看起来这些错误源于外部世界对我的网站发出的POST请求。目前我已禁用CSRF,但计划实施这样的解决方案: http://www.camroncade.com/disable-csrf-for-specific-routes-laravel-5/
答案 1 :(得分:1)
您可以捕获异常并像这样闪现用户:
if ($exception instanceof TokenMismatchException) {
return response()->redirect('login')->with('status', 'Token expired, please try again.');
}
将其放入App\Exceptions\Handler::render()
。
答案 2 :(得分:-1)
只需运行这些命令
php artisan clear-compiled
composer dump-autoload