-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guide to use Rate limiter with NuxtHub #612
Comments
Hey Buddy, Thanks for asking this question. I wonder, if you are already using Cloudflare, do they not provide already a rate limiting solution for their services? The built in rate limiting is suitable mainly for the simple use cases while for more advanced scenarios a better solution would be to use external rate limiting services. Also, this issue could be helpful -> #372 (comment) Based on it, could you try |
I have the ratelimiter setup on NuxtHub also, enabled globally. nuxt.config.ts;
This does work - in the headers I can see the limit decreasing and entries appear in my NuxtHub KV. I misconfigured a reverse proxy on my end, it actually works fine on NuxtHub/CloudFlare out of the box with the above setup. Make sure to configure the |
Thanks for sharing your code sample @GreenmeisterDavid Regarding the logging of one IP only, I think it could be related to the fact that there is not |
Apologies, I just tested it on another project and it actually works fine on Nuxthub/Cloudflare out of the box with the Cloudflare KV driver - I got the wrong IP before because of a misconfiguration with another layer of proxying on my end. @fayazara, can you try with setting the driver in the global options for the security module, like;
I tried both |
Is your feature request related to a problem? Please describe.
The current documentation doesn't cover how to properly integrate the rate limiter middleware with NuxtHub's KV storage when deploying to Cloudflare Workers. The default LRU cache driver doesn't work in a stateless environment like Cloudflare Workers, and while the rate limiter supports custom drivers including cloudflare-kv-binding, there's no clear guidance on how to properly configure it with NuxtHub's KV binding.
Describe the solution you'd like
A documentation section or guide that explains:
Describe alternatives you've considered
Attempted to use the cloudflare-kv-binding driver directly in the nuxt.config.ts:
However, this configuration doesn't work.
Additional context - TLDR
Using:
hub: { kv: true }
)The text was updated successfully, but these errors were encountered: