fix: 修复打包 lint 报错,版本号 1.1.1
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

middleware.ts 临时跳过认证的早 return 导致后续代码 unreachable,
TS 在不可达分支里不做类型 narrowing 触发 TS18048;
改为 BYPASS_AUTH 常量分支保留完整鉴权逻辑便于恢复。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
kkfluous
2026-04-15 16:53:01 +08:00
parent 820fde5547
commit 4acf10ef79
2 changed files with 9 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "ln-bi",
"private": true,
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"scripts": {
"dev": "concurrently -n server,client -c blue,green \"npm run dev:server\" \"npm run dev:client\"",

View File

@@ -4,16 +4,23 @@ import type { JwtPayload, AuthUser } from './types.js';
const JWT_SECRET = process.env.JWT_SECRET || 'ln-bi-default-secret';
// 临时:跳过所有认证(保留完整逻辑便于快速恢复)
const BYPASS_AUTH = true;
export async function authMiddleware(c: Context, next: Next) {
const path = c.req.path;
if (BYPASS_AUTH) {
return next();
}
// 跳过不需要认证的路径
if (path === '/api/health' || path.startsWith('/api/auth/')) {
return next();
}
const authHeader = c.req.header('Authorization');
if (!authHeader?.startsWith('Bearer ')) {
if (!authHeader || !authHeader.startsWith('Bearer ')) {
return c.json({ error: 'Unauthorized' }, 401);
}