回滚bug修复
This commit is contained in:
@@ -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,停止重定向');
|
||||
|
||||
Reference in New Issue
Block a user