Closed MickL closed 4 months ago
Hey,
In order to implement it correctly, you would need to define a driver like following:
rateLimiter: {
driver: {
name: 'vercel-kv';
options: { options };
};
}
It is explained in the docs here https://nuxt-security.vercel.app/documentation/middleware/rate-limiter#options
Do you think that it is not clear? I can try to rewrite it if it is confusing :)
driver
needs to be just a string name or a Unstorage driver object but at the same time linking to Unstorage which always creates a driver object:const storage = createStorage({
driver: vercelKVDriver({
});
vercelKv
. The configuration requires a pascal case name of the driver you want to use. It is then used in https://github.com/Baroshem/nuxt-security/blob/main/src/module.ts line 267 to mount the driver and it needs the pascal case name. That is why the defsult one is lruCache
not lru-cache
.If you use vercelKv
does the rate limiting work coreectly? I looked at the unstorage docs and the vercelKv is experimental.
Yes it works fine and I close this issue. Thanks for the quick responses! The docs need to be updated tho :)
Ok, so let me reopen this issue so that we can link the documentation fix to it :)
I will add documentation about using custom driver in the upcoming days
Managed to do it faster 😃
Added in https://github.com/Baroshem/nuxt-security/commit/4327422f973e7d340ed20aba51a5123838a1e286
Closing
I cant make another driver (vercel kv) work and the Docs dont explain how to do it. Am I supposed to put just the name string or the driver itself?
I tried:
And it actually works: If I refresh the page 4 times I am banned. But if I check the Vercel KV (Redis) it shows zero entries:
KEYS *
.