Spaces:
Sleeping
Sleeping
codex fix mutliple issues
Browse files- web/src/App.tsx +14 -9
web/src/App.tsx
CHANGED
|
@@ -880,15 +880,20 @@ function App() {
|
|
| 880 |
|
| 881 |
// Logout on page close or refresh
|
| 882 |
useEffect(() => {
|
| 883 |
-
const handleBeforeUnload =
|
| 884 |
if (sessionId) {
|
| 885 |
-
//
|
| 886 |
-
//
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 892 |
}
|
| 893 |
};
|
| 894 |
|
|
@@ -1980,4 +1985,4 @@ function App() {
|
|
| 1980 |
);
|
| 1981 |
}
|
| 1982 |
|
| 1983 |
-
export default App;
|
|
|
|
| 880 |
|
| 881 |
// Logout on page close or refresh
|
| 882 |
useEffect(() => {
|
| 883 |
+
const handleBeforeUnload = () => {
|
| 884 |
if (sessionId) {
|
| 885 |
+
// keepalive allows the request to continue during page unload.
|
| 886 |
+
fetch(`${GATEWAY_URL}/api/auth/logout`, {
|
| 887 |
+
method: 'POST',
|
| 888 |
+
headers: {
|
| 889 |
+
'Content-Type': 'application/json',
|
| 890 |
+
Authorization: `Bearer ${sessionId}`,
|
| 891 |
+
},
|
| 892 |
+
body: JSON.stringify({}),
|
| 893 |
+
keepalive: true,
|
| 894 |
+
}).catch(() => {
|
| 895 |
+
// Best-effort logout during unload; ignore failures.
|
| 896 |
+
});
|
| 897 |
}
|
| 898 |
};
|
| 899 |
|
|
|
|
| 1985 |
);
|
| 1986 |
}
|
| 1987 |
|
| 1988 |
+
export default App;
|