From d4cbbcbc2d46f65bdc15122f89883efa6d17f10c Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 Mar 2025 16:45:40 +0100 Subject: [PATCH] Fix session being double requested If the returned value of the fetched endpoint is blank that gets converted to undefined, which confuses the request sharing between the client and server causing the session to be requested on both sides. Transform value to null if it's blank so that the session fetch is de-duplicated. --- composables/session.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/composables/session.ts b/composables/session.ts index 1e45d39..579b43f 100644 --- a/composables/session.ts +++ b/composables/session.ts @@ -1 +1,6 @@ -export const useAccountSession = () => useFetch("/api/auth/session"); +export const useAccountSession = () => useFetch( + "/api/auth/session", + { + transform: (input) => input === undefined ? null : input, + } +);