From 1d6bb7147824f8790972b287ba8250c37976c982 Mon Sep 17 00:00:00 2001 From: ht Date: Sun, 6 Sep 2026 17:59:28 +0300 Subject: [PATCH] support CORS preflight requests --- server/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/index.js b/server/index.js index a1729ff..fb557b0 100644 --- a/server/index.js +++ b/server/index.js @@ -715,6 +715,16 @@ const aiJobRunner = startAiJobRunner(async (job,{signal}) => { const server = http.createServer(async (req, res) => { const url = new URL(req.url, `http://localhost:${PORT}`); + if (req.method === 'OPTIONS') { + res.writeHead(204, { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS', + 'Access-Control-Allow-Headers': 'Authorization,Content-Type', + 'Access-Control-Max-Age': '600', + }); + res.end(); + return; + } try { if (url.pathname === '/api/me/ai-jobs') { const user=userFromAuthHeader(req.headers.authorization);