mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-23 20:24:09 -05:00
fix: Set maxAge on frontend auth cookie (#6576)
This commit is contained in:
@@ -25,8 +25,11 @@ const authStatus = ref<"loading" | "authenticated" | "unauthenticated">("loading
|
|||||||
export const useAuthBackend = function (): AuthState {
|
export const useAuthBackend = function (): AuthState {
|
||||||
const { $axios } = useNuxtApp();
|
const { $axios } = useNuxtApp();
|
||||||
const router = useRouter();
|
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) {
|
function setToken(token: string | null) {
|
||||||
tokenCookie.value = token;
|
tokenCookie.value = token;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export default defineNuxtConfig({
|
|||||||
apiUrl: process.env.API_URL || "http://localhost:9000",
|
apiUrl: process.env.API_URL || "http://localhost:9000",
|
||||||
public: {
|
public: {
|
||||||
AUTH_TOKEN,
|
AUTH_TOKEN,
|
||||||
|
TOKEN_TIME: process.env.TOKEN_TIME || "48",
|
||||||
GLOBAL_MIDDLEWARE: process.env.GLOBAL_MIDDLEWARE || undefined,
|
GLOBAL_MIDDLEWARE: process.env.GLOBAL_MIDDLEWARE || undefined,
|
||||||
SUB_PATH: process.env.SUB_PATH || "",
|
SUB_PATH: process.env.SUB_PATH || "",
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|||||||
Reference in New Issue
Block a user