Skip to content

Commit 703f920

Browse files
committed
better handle session failure
1 parent 04f8da7 commit 703f920

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/App.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export default function App(): React.ReactElement {
3434
}
3535
}, [setUser, user]);
3636

37+
useEffect(() => {
38+
const params = new URLSearchParams(location.search);
39+
const existing = params.get("existing");
40+
41+
if (!existing) return;
42+
43+
location.replace(`${location.origin}/#${existing}?forceRefresh=true`);
44+
}, []);
45+
3746
useEffect(() => {
3847
if (searchParams.get("forceRefresh")) {
3948
displayToast("Session reloaded as you were timed out.");

src/helpers/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const callApi = async (toCall: string, init?: RequestInit | undefined): Promise<Response> => {
22
const response = await fetch(`${import.meta.env.VITE_API_PATH}${toCall}`, init)
33
if (response.status == 400) {
4-
location.replace(`${location.protocol}//${location.host}/#/?forceRefresh=true`)
4+
location.replace(`${location.protocol}//${location.host}/?existing=${location.hash.substring(1)}`)
55
}
66
return response
77
}

0 commit comments

Comments
 (0)