Spaces:
Sleeping
Sleeping
auto log off
Browse files- web/src/App.tsx +5 -9
web/src/App.tsx
CHANGED
|
@@ -111,16 +111,12 @@ function App() {
|
|
| 111 |
const handleBeforeUnload = async () => {
|
| 112 |
if (sessionId) {
|
| 113 |
// Use sendBeacon for reliable logout on page unload
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
// sendBeacon is more reliable than fetch during page unload
|
| 120 |
-
navigator.sendBeacon(
|
| 121 |
-
`${GATEWAY_URL}/api/auth/logout`,
|
| 122 |
-
JSON.stringify({})
|
| 123 |
);
|
|
|
|
| 124 |
}
|
| 125 |
};
|
| 126 |
|
|
|
|
| 111 |
const handleBeforeUnload = async () => {
|
| 112 |
if (sessionId) {
|
| 113 |
// Use sendBeacon for reliable logout on page unload
|
| 114 |
+
// Note: sendBeacon doesn't support custom headers, but the session is in the URL or body
|
| 115 |
+
const blob = new Blob(
|
| 116 |
+
[JSON.stringify({ sessionId })],
|
| 117 |
+
{ type: 'application/json' }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
);
|
| 119 |
+
navigator.sendBeacon(`${GATEWAY_URL}/api/auth/logout`, blob);
|
| 120 |
}
|
| 121 |
};
|
| 122 |
|