Handle connection error

This commit is contained in:
Luke Vella 2025-04-16 10:12:13 +01:00
parent 7f877689b2
commit 0bcc4cd9f1
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C

View file

@ -28,10 +28,17 @@ export async function rateLimit(
const session = await auth();
const identifier = session?.user?.id || (await getIPAddress());
try {
const ratelimit = new Ratelimit({
redis: kv,
limiter: Ratelimit.slidingWindow(requests, duration),
});
return ratelimit.limit(`${identifier}:${name}`);
} catch (e) {
console.error(e);
return {
success: true,
};
}
}