fix(ui): preserve sessionStorage token across beforeunload clear

The existing beforeunload handler calls sessionStorage.clear() to
flush cached UI data on page refresh. This also wiped the token
stored by storeLoginToken, re-introducing the redirect loop after
any page refresh in the HttpOnly proxy scenario. Now the token is
saved and restored across the clear.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hendrik Jaks 2026-03-13 12:15:39 +02:00
parent 35bd69e146
commit 01f8844114

View file

@ -97,7 +97,11 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
// They are only cleared on logout
useEffect(() => {
const handleBeforeUnload = () => {
const token = sessionStorage.getItem("token");
sessionStorage.clear();
if (token) {
sessionStorage.setItem("token", token);
}
};
window.addEventListener("beforeunload", handleBeforeUnload);
return () => window.removeEventListener("beforeunload", handleBeforeUnload);