diff --git a/src/pages/playlists/[playlistId]/snapshots.json.ts b/src/pages/playlists/[playlistId]/snapshots.json.ts index b9cdd98..87f1583 100644 --- a/src/pages/playlists/[playlistId]/snapshots.json.ts +++ b/src/pages/playlists/[playlistId]/snapshots.json.ts @@ -49,7 +49,7 @@ export const get: APIRoute = async ({ request, params }) => { }) ); - const body = JSON.stringify( + const payload = queryParams.get('allowDuplicates') === 'yes' ? possiblyDuplicateSnapshots : // Since commits are sorted by the latest dateCaptured first, @@ -62,8 +62,10 @@ export const get: APIRoute = async ({ request, params }) => { snapshot ]) ).values() - ] - ); + ]; + + const body = JSON.stringify(payload); + const ETag = payload[0].snapshotId; const cacheControlDirectives = Date.now() > untilDate.getTime() @@ -75,7 +77,7 @@ export const get: APIRoute = async ({ request, params }) => { headers: { 'Content-Type': 'application/json;charset=utf-8', 'Cache-Control': `public, ${cacheControlDirectives}`, - ETag: etag as string + ETag } }); } catch (error) {