How do I create a ratelimit on h3?
How can I create a ratelimit that blocks after a certain number of requests?
12 Replies
Hi @⛧ RedStar ⛧. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources provided do not contain explicit information or examples on how to implement rate limiting with h3 or in a Nuxt/Nitro server context. While there are details about server middleware and utilities in Nuxt, as well as how to use h3 helpers, there is no direct mention of rate limiting or how to block requests after a certain threshold is reached in these sources.
If you need to implement rate limiting, you may need to look for external h3 or Nitro plugins, or implement custom logic in server middleware, but the exact approach is not covered in the referenced documentation or examples above.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@605162125027049472> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai How do I implement it?
Let me check the knowledge base for you again. One moment! :books:
----------------------
I'm sorry, but the knowledge sources do not contain explicit information or examples on how to implement rate limiting with h3 or in a Nuxt/Nitro server context. There are details about creating server middleware and using h3 helpers in Nuxt, but nothing specifically about rate limiting or blocking requests after a certain number of requests. If you need to implement this, you may need to consult the h3 or Nitro documentation directly or look for third-party solutions, as the provided sources do not cover this topic.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@605162125027049472> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Where are you hosting? Most providers have it built in to their platform
this is one example: https://www.cloudflare.com/application-services/products/rate-limiting/
Advanced Rate Limiting & Brute Force Protection | Cloudflare
Cloudflare offers advanced rate limiting to protect against brute force attacks, DDoS attacks, and API abuse. Learn more about advanced rate limiting.
Cloudflare, But I need more control over how many times he can make the request, before he goes 429
Even the second courses
Cloudflare absolutly supports deciding what the pattern for requests need to be before blocking or even soft blocking like a shorter timeout. What specifically do you need to do?
Do you use nuxt hub? If yes you can easily bind a kv store to you app and use it to store et ip, user agent and nb of time this ip called you backend/worker
Yes, I can use useStorage for it?
Yah also
Just add a persitent store like redis by db by example