Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Rate Limiting: Global and for Guests/Users in Laravel

 

You can limit some URL to be called a maximum of 60 times per minute, with throttle:60,1.


Route::middleware('auth:api', 'throttle:60,1')->group(function ()
{
         Route::get('/user', function () {
             // TODO
         });
});

 

But also, you can do it separately for public and for logged-in users.


// maximum of 10 requests for guests, 60 for authenticated users
Route::middleware('throttle:10|60,1')->group(function () {
        //
});

 

Also, you can have a DB field users.rate_limit and limit the amount for specific user:


Route::middleware('auth:api', 'throttle:rate_limit,1')->group(function () {
        Route::get('/user', function () {
            //
       });
});

Comments

Add new comment

Restricted HTML

Search

Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.

 

Contact Us

All the content is FREE but I still need your help

 

Become a patreon