chore(auth): 未登录时 /auth/me 返回 loggedIn:false,避免登录页控制台 401 噪音
This commit is contained in:
+3
-3
@@ -432,11 +432,11 @@ async function handleAuth(req, res, pathname) {
|
||||
});
|
||||
}
|
||||
|
||||
// 当前登录态
|
||||
// 当前登录态(未登录返回 loggedIn:false,避免前端控制台出现 401 噪音)
|
||||
if (pathname === '/api/v1/auth/me' && method === 'GET') {
|
||||
const s = currentSession(req);
|
||||
if (!s) return fail(res, 401, 'UNAUTHORIZED', '未登录');
|
||||
return ok(res, { username: s.u, expiresAt: new Date(s.exp).toISOString() });
|
||||
if (!s) return ok(res, { loggedIn: false });
|
||||
return ok(res, { loggedIn: true, username: s.u, expiresAt: new Date(s.exp).toISOString() });
|
||||
}
|
||||
|
||||
// nginx auth_request 子请求:200 = 放行,401 = 跳登录
|
||||
|
||||
Reference in New Issue
Block a user