Fix rate limit variable scope
This commit is contained in:
parent
e47001365e
commit
c11484b910
1 changed files with 2 additions and 1 deletions
|
|
@ -20,10 +20,11 @@ export async function POST(request: Request) {
|
||||||
return NextResponse.json({ error: "Username and password required" }, { status: 400 });
|
return NextResponse.json({ error: "Username and password required" }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isSignup = action === "signup";
|
||||||
|
|
||||||
// Rate limiting - enable via RATE_LIMIT_ENABLED env var
|
// Rate limiting - enable via RATE_LIMIT_ENABLED env var
|
||||||
if (process.env.RATE_LIMIT_ENABLED !== "false") {
|
if (process.env.RATE_LIMIT_ENABLED !== "false") {
|
||||||
const ip = getClientIp(request);
|
const ip = getClientIp(request);
|
||||||
const isSignup = action === "signup";
|
|
||||||
const rateLimitResult = await rateLimit(
|
const rateLimitResult = await rateLimit(
|
||||||
getRateLimitKey(isSignup ? "admin-signup" : "admin-signin", ip),
|
getRateLimitKey(isSignup ? "admin-signup" : "admin-signin", ip),
|
||||||
{ max: isSignup ? 3 : 5, windowSec: isSignup ? 3600 : 900 }
|
{ max: isSignup ? 3 : 5, windowSec: isSignup ? 3600 : 900 }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue