From fbea9d8fcadbd49b789facf8fe0bd9a46f8a44f2 Mon Sep 17 00:00:00 2001 From: Kisaki Date: Tue, 28 May 2024 13:46:31 +0800 Subject: [PATCH] fix: webui options request --- modules/webui/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/webui/src/index.ts b/modules/webui/src/index.ts index 0e3fb974..ea4ae4c8 100644 --- a/modules/webui/src/index.ts +++ b/modules/webui/src/index.ts @@ -30,6 +30,9 @@ export function main(ctx: Context, cfg: Tsu.infer) { res.header('Access-Control-Allow-Methods', '*'); res.header('Content-Type', 'application/json;charset=utf-8'); + if (req.method === 'OPTIONS') return res.sendStatus(200); + ctx.logger.label(req.method).trace(req.path); + if (!router.find((item) => item.path === req.path || req.path.startsWith(item.path))) return res.status(404).send(); if (req.path === '/api/accounts/login' || ctx.webui.checkToken(req.headers.authorization)) return next(); return res.status(401);