fraudTech commited on
Commit
e7b9195
·
1 Parent(s): ec4e4ff

codex fix mutliple issues

Browse files
Files changed (1) hide show
  1. 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 = async () => {
884
  if (sessionId) {
885
- // Use sendBeacon for reliable logout on page unload
886
- // Note: sendBeacon doesn't support custom headers, but the session is in the URL or body
887
- const blob = new Blob(
888
- [JSON.stringify({ sessionId })],
889
- { type: 'application/json' }
890
- );
891
- navigator.sendBeacon(`${GATEWAY_URL}/api/auth/logout`, blob);
 
 
 
 
 
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;