fix(api): prevent self-loop routes, map P2003 to 400, forward DELETE error body

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 01:44:48 +05:30
parent 9d1799eab1
commit 5d9df64849
3 changed files with 25 additions and 3 deletions
+2 -1
View File
@@ -6,5 +6,6 @@ export async function DELETE(
) {
const { id } = await params;
const res = await fetch(`${API_URL}/routes/${id}`, { method: 'DELETE' });
return new Response(null, { status: res.status });
if (res.status === 204) return new Response(null, { status: 204 });
return Response.json(await res.json(), { status: res.status });
}