如何解决Laravel“有效载荷无效”的问题?

时间:2020-01-03 11:28:02

标签: php laravel

我的laravel应用程序仅在生产模式下存在很大问题...

我不知道它何时触发,但是这个网站每天大约有1万名访客,而我的laravel日志文件现在是如此之大。

在这里您可以找到日志:

The payload is invalid. {"exception":"[object] (Illuminate\\Contracts\\Encryption\\DecryptException(code: 0): The payload is invalid. at /home/web/abuk/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:195)
[stacktrace]
#0 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php(136): Illuminate\\Encryption\\Encrypter->getJsonPayload(NULL)
#1 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(154): Illuminate\\Encryption\\Encrypter->decrypt('eyJpdiI6Ik1wN0p...', false)
#2 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(136): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->getTokenFromRequest(Object(Illuminate\\Http\\Request))
#3 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(74): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->tokensMatch(Object(Illuminate\\Http\\Request))
#4 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#5 /home/web/abuk/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#6 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#7 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#8 /home/web/abuk/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))

我真的不知道它来自哪里。

3 个答案:

答案 0 :(得分:0)

尝试使用以下命令清除缓存:

php artisan cache:clear

不要忘记在表单中包含csrf https://laravel.com/docs/6.x/csrf

答案 1 :(得分:0)

请尝试以下操作: 1- PHP工匠清除;要么 2-确保您的应用程序生成了APP_KEY,如果没有生成php artisan key: 3-如果您使用的是Jwt,请确保已生成JWT_SECRET,否则请确保php artisan jwt:secret

答案 2 :(得分:0)

可能是您frogot _token的形式 @csrf