Set Expires: for viewing image.

This commit is contained in:
niknah
2025-11-03 19:47:05 +11:00
parent c0f2c9c0cf
commit 4fbace26ad
+4 -1
View File
@@ -63,9 +63,12 @@ export default defineEventHandler(async (event) => {
}
const width = parseInt(q.get('width'));
const expireAfterMs = 24 * 60 * 60 * 1000;
const expiresAt = new Date(Date.now() + expireAfterMs);
const disposition = q.has('download') ? 'download' : 'inline';
const headers = {
'Content-Disposition': `${disposition}; filename="${filename}"`,
'Content-Disposition': `${disposition}; filename="${filename}"`,
'Expires': expiresAt.toUTCString(),
};
if (width) {
// set expires so we don't have to resize every time.