Laravel 8 — Passport API Routing Rate Limiting

Jay Gao
Jan 18, 2021

In Laravel 8, the rate limiting has been improved.

For the api middleware, the rate limiting settings is now moved to the app/Providers/RouteServiceProvider.php file.

/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}

--

--