Another attempt to fix music cover file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
apatil 2025-05-07 22:54:59 +01:00
parent d9f84e45da
commit 369a89d7e6

View File

@ -5,7 +5,7 @@ export async function GET(req: NextRequest, { params }: { params: Promise<{ trac
const { track } = await params; const { track } = await params;
try { try {
const trackName = decodeURIComponent(track); const trackName = decodeURIComponent(track);
const filePath = resolve(process.cwd(), '/music', trackName); const filePath = resolve(process.cwd(), 'app/music', trackName);
const metadata = await mm.parseFile(filePath); const metadata = await mm.parseFile(filePath);
const picture = metadata.common.picture?.[0]; const picture = metadata.common.picture?.[0];
if (!picture) { if (!picture) {
@ -13,12 +13,12 @@ export async function GET(req: NextRequest, { params }: { params: Promise<{ trac
} }
return new Response(picture.data, { return new Response(picture.data, {
headers: { headers: {
'Content-Type': picture.format, 'Content-Type': picture.format || 'image/jpeg',
'Content-Length': picture.data.length.toString(), 'Content-Length': picture.data.length.toString(),
}, },
}); });
} catch (err) { } catch (err) {
console.log(err); console.error(err);
return new Response('Error retrieving cover', { status: 500 }); return new Response('Error retrieving cover', { status: 500 });
} }
} }