diff --git a/src/app/api/directory/route.ts b/src/app/api/directory/route.ts index 35f1b392..3d494b65 100644 --- a/src/app/api/directory/route.ts +++ b/src/app/api/directory/route.ts @@ -34,7 +34,7 @@ export async function GET(request: NextRequest) { const url = new URL(request.url); const search = url.searchParams.get("search") || ""; const tag = sanitizeSearchParams(url, "tag"); - const page = parseInt(url.searchParams.get("page") || "1"); + const page = Math.max(1, parseInt(url.searchParams.get("page") || "1") || 1); const limit = 20; const offset = (page - 1) * limit; diff --git a/src/app/api/notifications/route.ts b/src/app/api/notifications/route.ts index 1e2b3d60..8da0ec68 100644 --- a/src/app/api/notifications/route.ts +++ b/src/app/api/notifications/route.ts @@ -19,8 +19,8 @@ export async function GET(request: NextRequest) { const searchParams = request.nextUrl.searchParams; const unreadOnly = searchParams.get("unread") === "true"; - const limit = Math.min(Number(searchParams.get("limit")) || 50, 100); - const offset = Number(searchParams.get("offset")) || 0; + const limit = Math.min(Math.max(1, Number(searchParams.get("limit")) || 50), 100); + const offset = Math.max(0, Number(searchParams.get("offset")) || 0); let query = supabase .from("notifications") diff --git a/src/app/api/prompts/route.ts b/src/app/api/prompts/route.ts index 313bec28..31cebe78 100644 --- a/src/app/api/prompts/route.ts +++ b/src/app/api/prompts/route.ts @@ -15,7 +15,7 @@ export async function GET(request: NextRequest) { const category = url.searchParams.get("category") || ""; const tag = url.searchParams.get("tag") || ""; const sort = url.searchParams.get("sort") || "newest"; - const page = parseInt(url.searchParams.get("page") || "1"); + const page = Math.max(1, parseInt(url.searchParams.get("page") || "1") || 1); const limit = 20; const offset = (page - 1) * limit;