Fix rate limit variable scope

This commit is contained in:
Manohar Gupta 2026-05-17 01:14:32 +05:30
parent e47001365e
commit c11484b910

View file

@ -20,10 +20,11 @@ export async function POST(request: Request) {
return NextResponse.json({ error: "Username and password required" }, { status: 400 });
}
const isSignup = action === "signup";
// Rate limiting - enable via RATE_LIMIT_ENABLED env var
if (process.env.RATE_LIMIT_ENABLED !== "false") {
const ip = getClientIp(request);
const isSignup = action === "signup";
const rateLimitResult = await rateLimit(
getRateLimitKey(isSignup ? "admin-signup" : "admin-signin", ip),
{ max: isSignup ? 3 : 5, windowSec: isSignup ? 3600 : 900 }