fraudTech commited on
Commit
f8a8bbc
·
1 Parent(s): 0bfc226

auto log off

Browse files
Files changed (1) hide show
  1. 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
- const headers: HeadersInit = {
115
- 'Authorization': `Bearer ${sessionId}`,
116
- 'Content-Type': 'application/json'
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