diff --git a/netlify/edge-functions/now-playing.js b/netlify/edge-functions/now-playing.js
index 5e2dde04..322d1b91 100644
--- a/netlify/edge-functions/now-playing.js
+++ b/netlify/edge-functions/now-playing.js
@@ -46,13 +46,6 @@ export default async () => {
const TV_KEY = Netlify.env.get('API_KEY_TRAKT')
// eslint-disable-next-line no-undef
const MUSIC_KEY = Netlify.env.get('API_KEY_LASTFM')
- const headers = {
- headers: {
- 'Content-Type': 'application/json',
- 'Cache-Control': 'public, max-age=0, must-revalidate',
- 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
- },
- }
const traktRes = await fetch('https://api.trakt.tv/users/cdransf/watching', {
headers: {
@@ -73,7 +66,13 @@ export default async () => {
{
content: `📺 ${traktRes['show']['title']} • ${traktRes['episode']['title']}`,
},
- headers
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'public, max-age=0, must-revalidate',
+ 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
+ },
+ }
)
}
@@ -82,7 +81,13 @@ export default async () => {
{
content: `🎥 ${traktRes['movie']['title']}`,
},
- headers
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'public, max-age=0, must-revalidate',
+ 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
+ },
+ }
)
}
}
@@ -126,10 +131,22 @@ export default async () => {
if (isCorrectDate) {
if (nowHour === startHour && nowMinutes >= startMinutes && nowHour < endHour)
- return Response.json(res, headers)
+ return Response.json(res, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'public, max-age=0, must-revalidate',
+ 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
+ },
+ })
if (nowHour > startHour && nowHour < endHour) return Response.json(res)
if (nowHour > startHour && nowMinutes <= endMinutes && nowHour == endHour)
- return Response.json(res, headers)
+ return Response.json(res, {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'public, max-age=0, must-revalidate',
+ 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
+ },
+ })
}
}
}
@@ -177,7 +194,13 @@ export default async () => {
track['name']
} by ${track['artist']['#text']}`,
},
- headers
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'public, max-age=0, must-revalidate',
+ 'Netlify-CDN-Cache-Control': 'public, max-age=0, stale-while-revalidate=210',
+ },
+ }
)
}