fix(forms): resolve duplicate const h redeclaration in submitForm

The E2 rate-limit block (f11f4b3) added a second `const h = await
headers()` in submitForm where one already existed near the insert,
breaking the build (redeclaration). Renamed the rate-limit one to
rlHdrs. Build green, 532 tests. (f11f4b3 was committed before its
build was verified — process miss; never deployed.)
This commit is contained in:
Moheeb Zara
2026-05-19 02:12:36 -07:00
parent f11f4b3771
commit 9351969c96
+2 -2
View File
@@ -451,8 +451,8 @@ export async function submitForm(input: unknown) {
// Generous per-IP+form window because legitimate public signups at a
// hackerspace often share one NAT/wifi IP (a captcha is the real control,
// intentionally deferred). Best-effort IP from the proxy header.
const h = await headers()
const ip = (h.get('x-forwarded-for')?.split(',')[0] ?? '').trim() || 'unknown'
const rlHdrs = await headers()
const ip = (rlHdrs.get('x-forwarded-for')?.split(',')[0] ?? '').trim() || 'unknown'
const rl = checkRateLimit(`form-submit:${ip}:${form.id}`, 20, 60_000)
if (!rl.allowed) {
return { error: 'Too many submissions from your network. Please wait a moment and try again.' }