回滚bug修复

This commit is contained in:
2026-04-14 14:19:19 +08:00
parent cda3c3345f
commit a08d725104
2 changed files with 21 additions and 0 deletions

View File

@@ -52,6 +52,16 @@ async function apiRequest(url, options = {}) {
if (response.status === 401) {
clearAuth();
// 同步清除 PHP Session防止 index.php 302 重定向循环
try {
await fetch('/api/clear_session.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
} catch (e) {
console.warn('[Auth] 清除PHP Session失败:', e);
}
// 防循环机制:检查是否已在登录页
if (window.location.pathname === '/index.php' || window.location.pathname === '/') {
console.warn('[Auth] 已在登录页收到401停止重定向');