Abort caption requests when they are not in view to tax the server less.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user