feat: Upstash implementation for rate limiting/redis (#9514)
* Introduce rate limiting that works on the edge * typo * Log once on init * Update rateLimit.ts --------- Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
ed65b2a3ab
commit
8eccd3658e
9 files changed
+124
-44
No files matched your search
@@ -28,3 +28,13 @@ export function isIpInBanlist(request: Request | NextApiRequest) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isIpInBanListString(identifer: string) {
|
||||
const rawBanListJson = process.env.IP_BANLIST || "[]";
|
||||
const banList = banlistSchema.parse(JSON.parse(rawBanListJson));
|
||||
if (banList.includes(identifer)) {
|
||||
console.log(`Found banned IP: ${identifer} in IP_BANLIST`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user