Skip to content

Commit

Permalink
fix(frontend): handle backend status and fallback to demo version
Browse files Browse the repository at this point in the history
Ensure correct storage of backend status and handle the scenario where the backend is not available by falling back to the demo version of the app.
  • Loading branch information
sajjadth committed Nov 25, 2023
1 parent 3f59d88 commit 447a339
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/middleware/setup.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ async function checkBackendStatus() {
})
.then((res) => res.json())
.then((data) => {
// stora status of backend
store.$patch({ isBackendReady: data.status === 200 });
if (data.status === 200 || data.status === 503)
// stora status of backend
store.$patch({ isBackendReady: data.ok });
// if backend is not up and running then use demo version of app
if (!store.isBackendReady) {
const tokenInLocalStorage =
String(localStorage.getItem("loggedIn")) ||
String(sessionStorage.getItem("loggedIn")) ||
null;
JSON.parse(localStorage.getItem("loggedIn") as any) ||
JSON.parse(sessionStorage.getItem("loggedIn") as any);
store.$patch({ token: tokenInLocalStorage as any });
}
})
Expand Down

0 comments on commit 447a339

Please sign in to comment.