use login?expired=true for unauthorized logout

This commit is contained in:
Fran Jurmanović
2025-09-22 23:29:30 +02:00
parent 6563396a83
commit 0cbc6935db
4 changed files with 95 additions and 77 deletions

View File

@@ -49,7 +49,7 @@ export async function fetchClientAPI<T>(
if (!response.ok) {
if (response.status === 401) {
window.location.href = '/login';
window.location.href = '/login?expired=true';
return { error: 'unauthorized' };
}
throw new Error(`API Error: ${response.statusText} - ${method} - ${BASE_URL}${endpoint}`);

View File

@@ -12,7 +12,7 @@ export async function requireAuth(skipRedirect?: boolean) {
const session = await getSession();
if (!skipRedirect && (!session.token || !session.user)) {
redirect('/login');
redirect('/login?expired=true');
}
return session;