diff --git a/functions/api/infractions/new.ts b/functions/api/infractions/new.ts index 0599a81..aa30ef8 100644 --- a/functions/api/infractions/new.ts +++ b/functions/api/infractions/new.ts @@ -77,6 +77,12 @@ export async function onRequestPost(context: RequestContext) { // @ts-expect-error const files: File[] = body.keys().find((key) => key.match(/^files\[\d]$/)); const urlPromises = []; + const origin = context.request.headers.get("Origin"); + + if (!origin) + return new Response('{"error":"Origin header missing"}', { + status: 400, + }); for (const file of files) { if (!allowedFileTypes.includes(file.type)) @@ -97,6 +103,7 @@ export async function onRequestPost(context: RequestContext) { attachmentKey, file.size, (allowedFileTypes.find((t) => t === file.type) as string).split("/")[1], + origin, ), ); }