The GET /api/directory endpoint parses the page query parameter without clamping it to a valid range.
Repro
GET /api/directory?page=-1
Observed:
page = parseInt("-1") = -1 (truthy, so the || 1 fallback is skipped)
offset = (-1 - 1) * 20 = -40
- Supabase
.range(-40, -21) call returns a database error (500)
Fix
Clamp page to a minimum of 1:
const page = Math.max(1, parseInt(url.searchParams.get("page") || "1") || 1);
The
GET /api/directoryendpoint parses thepagequery parameter without clamping it to a valid range.Repro
Observed:
page = parseInt("-1") = -1(truthy, so the|| 1fallback is skipped)offset = (-1 - 1) * 20 = -40.range(-40, -21)call returns a database error (500)Fix
Clamp
pageto a minimum of1: