rough session timeout

This commit is contained in:
2026-03-19 03:00:09 +00:00
parent 5f15d92903
commit f3d6df2f82
5 changed files with 82 additions and 5 deletions

View File

@@ -0,0 +1,15 @@
export default defineNuxtPlugin((nuxtApp) => {
const showTimeout = useState('showSessionTimeout', () => false);
const isLoggedIn = useState('isLoggedIn');
nuxtApp.hooks.hook('app:suspense:resolve', () => {
globalThis.$fetch = $fetch.create({
onResponseError({ response }) {
if (response.status === 401 && isLoggedIn.value) {
isLoggedIn.value = false;
showTimeout.value = true;
}
}
});
});
});