feat(api): add input validation to AI endpoints
Add prompt validation to ai-event (non-empty string, max 2000 chars) and events array length validation to ai-summary (max 100 items) to prevent abuse and injection attacks.
This commit is contained in:
@@ -23,6 +23,12 @@ export async function POST(request: Request) {
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
if (events.length > 100) {
|
||||
return NextResponse.json(
|
||||
{ error: "Events array must contain 100 or fewer items" },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user