diff --git a/functions/codeblock/src/index.ts b/functions/codeblock/src/index.ts index b3af3d3..0123832 100644 --- a/functions/codeblock/src/index.ts +++ b/functions/codeblock/src/index.ts @@ -67,6 +67,16 @@ export function handler({ export default { async fetch(request: Request): Promise { + if (request.method === "OPTIONS") { + return new Response("", { + headers: { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "POST", + "Access-Control-Allow-Headers": "Content-Type", + }, + }); + } + const message = await request.json(); const response = handler(message); @@ -74,6 +84,9 @@ export default { status: response.statusCode, headers: { "Content-Type": "application/json", + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "POST", + "Access-Control-Allow-Headers": "Content-Type", }, }); },