Throttle with Precognition #51862
Unanswered
joaopalopes24
asked this question in
Ideas
Replies: 1 comment 2 replies
-
Agree with this idea. I hope it can be implemented soon. I also encounter this problem with my Precognitive routes, and for now, my workaround was checking whether the request has public function boot(): void
{
RateLimiter::for('my-throttled-routes', function (Request $request) {
if (! $request->hasHeader('Precognition')) {
// set the $decayMinutes and $maxAttempts to your needs
return Limit::perMinutes($decayMinutes = 5, $maxAttempts = 15)->by('your-defined-throttle-key');
}
});
// the rest of boot method
} So in the Route::middleware('throttle:my-throttled-routes')->group(function() {
// define your precognitive and throttled routes here
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have one post route that uses the precognition:
Route::post('forgot-password', [Auth\PasswordResetLinkController::class, 'store'])->middleware('throttle:6,1');
Since this route has the throttle too, if I call this route, even with errors, the rate limiter is filled. I think you could create anything to bypass the throttle when the request is for precognition.
Route::post('forgot-password', [Auth\PasswordResetLinkController::class, 'store'])->middleware('throttle:6,1')->ignorePrecognition();
Beta Was this translation helpful? Give feedback.
All reactions