I have a group of endpoints that I want to have a throttle of 10 requests per minute. Currently, my endpoint group looks like this:
Route::group([
'middleware' => 'auth:api', 'throttle:10,1'
], function () {
// endpoints here
}
The issue is that when I view my headers, the rate limit is set at the standard 60 per minute. What am I doing wrong? Or do you know a different way?
The response data is as follows:
cache-control: no-cache, private
content-encoding: gzip
content-type: application/json
date: Tue, 01 May 2018 20:08:55 GMT
server: nginx/1.14.0 (Ubuntu)
status: 200
vary: Accept-Encoding
x-ratelimit-limit: 60
x-ratelimit-remaining: 59
I tried the following:
Route::group([
'middleware' => ['auth:api', 'throttle:10,1']
], function () {
// rest of code
But got the same result. So then I tried:
Route::group([
'middleware' => 'throttle:10,1', 'auth:api'
], function () {
// rest of code
However, this gave me a 500 error. This told me that the middleware definitely had to be an array. However, when it is an array, it doesn't set the throttle to what I want it to be.
I have no way to test this, but I suspect you want:
Route::group([
'middleware' => ['auth:api', 'throttle:10,1']
], function () {
// rest of code
That is, without putting 'auth:api'
and 'throttle:10,1'
into one array Laravel has no way to understand that the latter is also middleware.