Abort caption requests when they are not in view to tax the server less.

This commit is contained in:
Jaret Burkett
2026-03-30 10:46:25 -06:00
parent a484e55d66
commit b43ea6c2d3
2 changed files with 24 additions and 13 deletions

View File

@@ -5,8 +5,18 @@ import path from 'path';
import { getDatasetsRoot } from '@/server/settings';
export async function POST(request: NextRequest) {
const body = await request.json();
let body;
try {
body = await request.json();
} catch {
// Client aborted the request before body was fully sent
return new NextResponse(null, { status: 499 });
}
if (request.signal.aborted) {
return new NextResponse(null, { status: 499 });
}
const { imgPath } = body;
console.log('Received POST request for caption:', imgPath);
try {