diff --git a/client/src/stores/user.ts b/client/src/stores/user.ts index 09d6fb7c..83bc6bbe 100644 --- a/client/src/stores/user.ts +++ b/client/src/stores/user.ts @@ -3,6 +3,8 @@ import * as log from "loglevel"; import { itGet, itPost } from "@/fetchHelpers"; import { useAppStore } from "@/stores/app"; import { defineStore } from "pinia"; + +const logoutRedirectUrl = import.meta.env.VITE_LOGOUT_REDIRECT; // typed state https://stackoverflow.com/questions/71012513/when-using-pinia-and-typescript-how-do-you-use-an-action-to-set-the-state export type UserState = { @@ -53,7 +55,15 @@ export const useUserStore = defineStore({ handleLogout() { itPost("/api/core/logout/", {}).then((data) => { Object.assign(this, initialUserState); - window.location.href = "/"; + + let redirectUrl; + + if (logoutRedirectUrl !== "") { + redirectUrl = logoutRedirectUrl; + } else { + redirectUrl = "/"; + } + window.location.href = redirectUrl; }); }, fetchUser() {