fix: Set maxAge on frontend auth cookie (#6576)

This commit is contained in:
Michael Genson
2025-11-20 15:18:27 -06:00
committed by GitHub
parent 6d4f573526
commit c4a3068492
2 changed files with 6 additions and 2 deletions

View File

@@ -25,8 +25,11 @@ const authStatus = ref<"loading" | "authenticated" | "unauthenticated">("loading
export const useAuthBackend = function (): AuthState {
const { $axios } = useNuxtApp();
const router = useRouter();
const tokenName = useRuntimeConfig().public.AUTH_TOKEN;
const tokenCookie = useCookie(tokenName);
const runtimeConfig = useRuntimeConfig();
const tokenTimeHours = Number(runtimeConfig.public.TOKEN_TIME) || 48;
const tokenName = runtimeConfig.public.AUTH_TOKEN;
const tokenCookie = useCookie(tokenName, { maxAge: tokenTimeHours * 60 * 60 });
function setToken(token: string | null) {
tokenCookie.value = token;