diff --git a/src/proxy/rate-limit.ts b/src/proxy/rate-limit.ts index c8acf8f..b70e249 100644 --- a/src/proxy/rate-limit.ts +++ b/src/proxy/rate-limit.ts @@ -83,7 +83,7 @@ export const refundLastAttempt = (req: Request) => { const key = req.user?.token || req.risuToken || req.ip; const attempts = lastAttempts.get(key) || []; attempts.pop(); -} +}; export const ipLimiter = async ( req: Request, @@ -109,7 +109,9 @@ export const ipLimiter = async ( return next(); } - const type = req.baseUrl + req.path ? "image" : "text"; + const type = (req.baseUrl + req.path).includes("openai-image") + ? "image" + : "text"; const limit = type === "image" ? imageLimit : textLimit; // If user is authenticated, key rate limiting by their token. Otherwise, key