N
Nuxt5mo 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"
});
}
}
}
});
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?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server