Enabling rate limit on all routes #350
-
Hey ! When the user makes a GET request to a valid endpoint (I'm building an API) in my code too many times, the limit is successfully triggered. But when the endpoint is not valid, for exemple : How to enable it everywhere ? I mean, when a single request is made to an invalid endpoint, I still want to return my error message, but if it's repetitive calls, I want to limit the queries. thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Normally it depends on what order things are defined in, although, I'm not sure in the case of an error handler. Did you set up the error handler before the rate limiter? If so, try switching them. If not, or if that doesn't work, could you post a snippet of your code? |
Beta Was this translation helpful? Give feedback.
-
Thank for you answer.
If you need other info, don't hesitate. Cheers |
Beta Was this translation helpful? Give feedback.
-
Thanks for you feedback, I've tested your code, it works indeed.
In between, I'm rather opting for a server cache, I think this is a preferable option. I used the simple provided example from the documentation (without handler) :
|
Beta Was this translation helpful? Give feedback.
Here's an example that works for me (I tested it rn) -