From 3897c87a4db000b71fa592efd60b936ec04a4e1b Mon Sep 17 00:00:00 2001 From: Ted Schaefer Date: Tue, 21 May 2024 22:29:59 -0700 Subject: [PATCH] Add missing null check in get clip. --- src/app/api/clip/route.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/api/clip/route.ts b/src/app/api/clip/route.ts index 9e00478..6d129f5 100644 --- a/src/app/api/clip/route.ts +++ b/src/app/api/clip/route.ts @@ -9,6 +9,16 @@ export async function GET(req: NextRequest) { try { const url = new URL(req.url); const clipId = url.searchParams.get('id'); + if (clipId == null) { + return new NextResponse(JSON.stringify({ error: 'Missing parameter id' }), { + status: 400, + headers: { + 'Content-Type': 'application/json', + ...corsHeaders + } + }); + } + const audioInfo = await (await sunoApi).getClip(clipId); return new NextResponse(JSON.stringify(audioInfo), {