I'm working with Laravel 5.8 and I wanted to set up a Rate Limiter that limits accessing to route by per minute and also IP address.
So I added this to RouteServiceProvider.php
:
protected function configureRateLimiting()
{
RateLimiter::for('limited', function (Request $request) {
return [
Limit::perMinute(500),
Limit::perMinute(20)->by($request->ip()),
];
});
}
And then applied it to Route:
Route::get("/", "StaticPages\HomeController@show")->middleware('throttle:limited')->name('home');
So it should be limiting access after 500 attempts or 20 attempts from the same IP address.
But now the problem is it shows 429 Too Many Requests after only ONE attempt!
I don't know why it limits the access after only one attempt.
So what's going wrong here?
How can I properly set the limitation based on IP address to 20 and 500 requests per minute?