krs's avatar
Level 17

Disabling route rate limiting

Hello!

I need to disable route throtteling on a specific route, so I tried ->withoutMiddleware(ThrottleRequests::class); on the route in the routes/api.php. Shouldn't this do the trick?

But I still get a "too many attempts" after around 585 requests (I have set the rate limit to throttle:300,1 in http/kernel.php).

579 / 6658 {"error":false}
580 / 6658 {"error":false}
581 / 6658 {"error":false}
582 / 6658 {"error":false}
583 / 6658 {"error":false}
584 / 6658 {"error":false}
585 / 6658 {
    "message": "Too Many Attempts."
}
586 / 6658 {
    "message": "Too Many Attempts."
}
587 / 6658 {
    "message": "Too Many Attempts."
}
588 / 6658 {
    "message": "Too Many Attempts."
}

I also tried ->excludedMiddleware(ThrottleRequests::class);, but same effect. I also cleared the route:cache and the config:cache, I used php artisan optimize, always the same.

What I am missing? Thanks, Stefan

0 likes
2 replies
krs's avatar
Level 17

Hi @silencebringer, thank you for your tip! Yeah, after reading the issues and comments I looked up for it in the docs, and NOW I read, withoutMiddleware does not work with global middleware... It's at the very bottom of this section:

The withoutMiddleware method can only remove route middleware and does not apply to global middleware.

Please or to participate in this conversation.