NuxtN
Nuxt2y ago
Cesxhin

It doesn't block passed requests when I have a middleware that checks whether you are authenticated.

I installed plugin nuxt security and i set tokensPerInterval: 1000 and interval: 60000.

export default defineEventHandler((event) => {
    const notRequireAuth = ["/api/public"];
    const {auth} = parseCookies(event);
    const path = event.path;

    if(startsWith(path, "/api")){
        if(isEmpty(find(notRequireAuth, (url) => path.indexOf(url) !== -1))){
            if(isNil(auth)){
                throw createError({
                    statusCode: 401,
                    statusMessage: "You aren't authenticated"
                });
            }
        }
    }
});


How block with "too many request" also form this middleware?
Was this page helpful?