Did you find a solution?
Getting remaining time from a RateLimiter Blocked request
My rateLimiter is something like this:
RateLimiter::for('changes', function (Request $request) {
return Limit::perMinutes(2, 1)->by($request->user()?->id)->response(function (Request $request, array $headers) {
return response([
'remaining' => RateLimiter::availableIn($request->user()->id),
'ip' => $request->ip()
], 429, $headers);
});
});
What I want to do: Get the time remaining back in the event the request is throttled. User can only hit the request once per two minutes
Calling the availableIn method via the RateLimiter facade passes the key but the key stored in cache is somehting else which results in the max function in the source code always output a value of 0. for example I was passing the key of user id => 1,
it is stored in the cache as something of the sort 'feb23434dsdfh234sdfsdf:timer' something like this, but when I use the facade to call the availableIn method the key passed is simply 1
Please or to participate in this conversation.