The GET /api/prompts endpoint parses the page query parameter without clamping it to a valid range — same issue as the directory and other listing endpoints.
Repro
Observed:
page = parseInt("-1") = -1 (truthy, so || 1 fallback is skipped)
offset = (-1 - 1) * 20 = -40
- Supabase
.range(-40, -21) 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/promptsendpoint parses thepagequery parameter without clamping it to a valid range — same issue as the directory and other listing endpoints.Repro
Observed:
page = parseInt("-1") = -1(truthy, so|| 1fallback is skipped)offset = (-1 - 1) * 20 = -40.range(-40, -21)returns a database error (500)Fix
Clamp
pageto a minimum of1: