Merge pull request #82 from 6bangs/main

Add missing null check in get clip.
This commit is contained in:
blueeon 2024-05-26 21:12:04 +08:00 committed by GitHub
commit 6c7b2de443
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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), {