feat: 优化 getToken 函数,移除无用的响应参数,调整授权过滤逻辑以支持新路径
This commit is contained in:
@@ -34,7 +34,7 @@ const authFilter = async (req: http.IncomingMessage, res: http.ServerResponse) =
|
||||
return false;
|
||||
}
|
||||
// 放开首页
|
||||
if (pathname.startsWith('/root/home')) {
|
||||
if (pathname.startsWith('/root/home') || pathname === '/root/cli') {
|
||||
return false;
|
||||
}
|
||||
// 放开api, 以 /api, /v1, /client, /serve 开头的请求
|
||||
@@ -47,8 +47,11 @@ const authFilter = async (req: http.IncomingMessage, res: http.ServerResponse) =
|
||||
if (share === 'public') {
|
||||
return false;
|
||||
}
|
||||
const { token } = await getToken(req, res)
|
||||
const { token } = await getToken(req)
|
||||
if (!token) {
|
||||
// no token 转到登录页面
|
||||
res.writeHead(302, { Location: `/root/home/` });
|
||||
res.end();
|
||||
return false;
|
||||
}
|
||||
const tokenUser = await getTokenUserCache(token);
|
||||
|
||||
Reference in New Issue
Block a user