Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: webui options request
Browse files Browse the repository at this point in the history
BIYUEHU authored May 28, 2024
1 parent 2593ca8 commit fbea9d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/webui/src/index.ts
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@ export function main(ctx: Context, cfg: Tsu.infer<typeof config>) {
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);

0 comments on commit fbea9d8

Please sign in to comment.