Laravel 中的 Too Many Attempts 错误一般是处在 api 开发中,这是因为启用了限流中间件 throttle,该中间件一般在 app/Http/Kernel.php
中定义使用:
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
throttle:60,1
,即设置频率限制为每分钟 60 次,如果一个 IP 一分钟内超过这个限制,那么服务器就会返回 429 Too Many Attempts.
响应。将该限制根据实际情况增加即可。