security/feat: no need for api on lastplayed, greatly improve logging+interface+ status of music widget
This commit is contained in:
parent
2710b278a3
commit
01ca6545fd
7 changed files with 268 additions and 43 deletions
21
app/api/now-playing/route.ts
Normal file
21
app/api/now-playing/route.ts
Normal 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 })
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue