Change ETag to the latest snapshot's ID

This commit is contained in:
Maciej Pędzich 2023-01-22 20:43:36 +01:00
parent 926e4ad512
commit 72dd818def

View File

@ -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) {