Skip to content

Commit

Permalink
fix: if api 401, reload page by hack fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed Mar 20, 2024
1 parent 3089fcf commit d3945a3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
document.documentElement.classList.add("dark");
}
</script>
<script>
var originalFetch = window.fetch;
window.fetch = function (url, options) {
return originalFetch(url, options)
.then(response => {
// if the response is unauthorized, reload the page for re-authentication
if (response.status === 401) {
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
return response;
}
});
};
</script>
</head>
<body>
<div id="root"></div>
Expand Down

0 comments on commit d3945a3

Please sign in to comment.