Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rst630's avatar

Api route throttling by default

Jetstream / Inertia

    protected $middlewareGroups = [
        'api' => [
            EnsureFrontendRequestsAreStateful::class,
            'throttle:api',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];

by default throttle:api enabled in api section. When I doing axios.get(/api/user) or any other api route, I got answer delay 3-4 sec and huge load on server (CPU) even if I request this route 1 time per 3 sec. Even if in route just closure which return immediatly.

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return 1;
});

Why this happens? If I disabling 'throttle:api' - all works fine and I got answer from endpoint in 80-100ms

0 likes
4 replies
bugsysha's avatar

Is that a new project or an old one? If new then try on other server. If old then try new install and see how it behaves.

rst630's avatar

Laravel Framework 8.11.2

it's a fresh install.

I saw in other my install that throttle set to "throttle:60,1" - I tried in this install these values too but it's not helped - still throttling even in headers it says 59 requests remaining

wingly's avatar

You can change that in your RouteServiceProvider@configureRateLimiting method.

rst630's avatar
    protected function configureRateLimiting()
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60);
        });
    }

Here all by default, Im not reaching limits - I got 3-4 sec delay on first and next answers from api routes.

As I know if I reach limit it will response with error

Please or to participate in this conversation.