海滨擎蟹

[PHP] 解决laravel 报错:Too Many Attempts

这个是限流中间件 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,1 到这个 throttle 中,但好在网上有解读文章:Laravel 访问限制 throttle 中间件throttle:60,1,即设置频率限制为每分钟 60 次,如果一个 IP 一分钟内超过这个限制,那么服务器就会返回 429 Too Many Attempts. 响应。

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »