From 6b87f2d0fc10c45f86bb0de094c33e328b001469 Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Tue, 7 Jan 2025 19:09:07 +0100 Subject: [PATCH] Refac use Routes constant for logout --- frontend/src/functions/APIClient.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/functions/APIClient.ts b/frontend/src/functions/APIClient.ts index 427e2ed0..21a5e734 100644 --- a/frontend/src/functions/APIClient.ts +++ b/frontend/src/functions/APIClient.ts @@ -3,6 +3,7 @@ import getApiUrl from '../configuration/getApiUrl'; import getFetchCredentials from '../configuration/getFetchCredentials'; import logOut from '../api/actions/logOut'; import getCookie from './getCookie'; +import Routes from '../configuration/routes/RouteList'; export interface ApiClientOptions extends Omit { method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; @@ -31,13 +32,13 @@ const APIClient = async ( // Handle common errors if (response.status === 401) { logOut(); - window.location.href = '/login'; + window.location.href = Routes.Login; throw new Error('Unauthorized: Redirecting to login.'); } if (response.status === 403) { logOut(); - window.location.href = '/login'; + window.location.href = Routes.Login; throw new Error('Forbidden: Access denied.'); }