security/feat: no need for api on lastplayed, greatly improve logging+interface+ status of music widget

This commit is contained in:
Aidan 2025-03-28 15:00:11 -04:00
parent 2710b278a3
commit 01ca6545fd
7 changed files with 268 additions and 43 deletions

View file

@ -0,0 +1,21 @@
import { NextResponse } from 'next/server'
export async function GET() {
try {
const response = await fetch("https://api.listenbrainz.org/1/user/p0ntus/playing-now", {
headers: {
Authorization: `Token ${process.env.LISTENBRAINZ_TOKEN}`,
},
})
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`)
}
const data = await response.json()
return NextResponse.json(data)
} catch (error) {
console.error('Error fetching now playing:', error)
return NextResponse.json({ error: 'Failed to fetch now playing data' }, { status: 500 })
}
}