Release 0.5.1
This commit is contained in:
1 parent
5a9d7735d4
commit
fb24d171ae
36 files changed
+5099
-263
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { requireUser } from '#lib/server/auth.js';
|
||||
import { getPiece } from '#lib/server/content.js';
|
||||
import { fetchPresentationImage } from '#lib/server/presentation.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ locals, params }) => {
|
||||
requireUser(locals.user);
|
||||
const piece = getPiece(params.id);
|
||||
if (!piece?.presentationImageUrl) error(404, 'Vorschaubild nicht verfügbar');
|
||||
try {
|
||||
const image = await fetchPresentationImage(piece.presentationImageUrl);
|
||||
return new Response(new Uint8Array(image.data), {
|
||||
headers: {
|
||||
'Content-Type': image.mimeType,
|
||||
'Content-Length': String(image.data.byteLength),
|
||||
'Cache-Control': 'private, max-age=300',
|
||||
'X-Content-Type-Options': 'nosniff',
|
||||
'Cross-Origin-Resource-Policy': 'same-origin',
|
||||
'Content-Security-Policy': "default-src 'none'; sandbox"
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
error(404, 'Vorschaubild nicht verfügbar');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user