fix: API 인증 실패 시 401 반환 (리다이렉트 대신)
페이지 이동 후 사이트 목록 빈 화면 버그 수정 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -42,7 +42,10 @@ function adminAuth(req, res, next) {
|
||||
}
|
||||
sessions.delete(token);
|
||||
}
|
||||
// 로그인 페이지로 리다이렉트
|
||||
// API 요청은 401 반환, 페이지 요청은 로그인으로 리다이렉트
|
||||
if (req.path.startsWith('/api')) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
const returnUrl = req.originalUrl;
|
||||
res.redirect('/login?redirect=' + encodeURIComponent(returnUrl));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user