Skip to content

armgit / ARTEX

Public Imported from GitHub
0

ARTEX - AI autonomous penetration testing system (English translation; upstream: Autumn-27/ARTEX, AGPL-3.0)

fix(web): 守卫跳转登录页前清除 cookie,修复 cookie 与 localStorage 不一致导致的无限重定向白屏

Autumn-2766a9fc4deebf
diff --git a/web/src/app/(main)/layout.tsx b/web/src/app/(main)/layout.tsx
index fef8c20..1022dfc 100644
--- a/web/src/app/(main)/layout.tsx
+++ b/web/src/app/(main)/layout.tsx
@@ -37,6 +37,10 @@ export default function Layout({ children }: Readonly<{ children: ReactNode }>)
if (auth.getToken()) {
setAuthed(true);
} else {
+ // 客户端守卫认为未登录时,必须同时清掉 cookie:否则 proxy.ts 仅凭
+ // “cookie 存在”就把我们从 /login 又重定向回主界面,与本守卫来回弹跳
+ // 形成无限重定向 → 白屏(cookie 与 localStorage 不一致时触发)。
+ auth.clearToken();
window.location.href = "/login";
}
}, []);