nuxt api shield, rate limit bug

my code, which I expect to only take one fetch event every 10 seconds doesn't work as expected. instead it takes all the fetch events for a while, is it a time interval?. doesn't matter how many, I counted 15, before it blocks all.
export const config = {
apiShield: {
rateLimiter: {
enabled: true,
tokensPerInterval: 1,
interval: '10s',

onRateLimitExceeded(event: any) {
const ip = getRequestIP(event)
console.log(`[Rate Limit] IP ${ip} exceeded download rate limit at ${new Date().toISOString()}`)

throw createError({statusCode: 429, statusMessage: 'Too many requests. Try again later.'});
}


}
}
}

export default defineEventHandler(async (event) => {

const body = await readBody(event);
console.log("Logging download:", body);
return {status: 'ok'};

});
export const config = {
apiShield: {
rateLimiter: {
enabled: true,
tokensPerInterval: 1,
interval: '10s',

onRateLimitExceeded(event: any) {
const ip = getRequestIP(event)
console.log(`[Rate Limit] IP ${ip} exceeded download rate limit at ${new Date().toISOString()}`)

throw createError({statusCode: 429, statusMessage: 'Too many requests. Try again later.'});
}


}
}
}

export default defineEventHandler(async (event) => {

const body = await readBody(event);
console.log("Logging download:", body);
return {status: 'ok'};

});
nothing else except a blank config
modules: ["nuxt-api-shield"],

nuxtApiShield: {

},
// ...
modules: ["nuxt-api-shield"],

nuxtApiShield: {

},
// ...
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @Thick Black W. 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 any information about "nuxt-api-shield" or its rate limiting behavior, configuration, or known bugs. There is no mention of an "apiShield" or rate limiter configuration in the official Nuxt documentation or related sources above. As such, I cannot provide a confident answer or troubleshooting steps for your specific issue with the rate limiter in "nuxt-api-shield". If you are using a third-party module not covered in the official Nuxt documentation or the sources above, I recommend checking the module's own documentation or issue tracker for more details. If you have questions about Nuxt's built-in features or official modules, feel free to ask! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@1321238874634195004> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?