From e54d7b9d77d4ecdebb517ae6df6ed2007792bf8a Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Fri, 2 Aug 2024 17:38:44 +0100 Subject: [PATCH] fix: set cookie path correctly --- packages/core/src/utils/cookie.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/cookie.ts b/packages/core/src/utils/cookie.ts index 06814c3347..77270bfa3b 100644 --- a/packages/core/src/utils/cookie.ts +++ b/packages/core/src/utils/cookie.ts @@ -10,7 +10,9 @@ export const cookieStorage = { }, setItem(key, value) { if (typeof window === 'undefined') return - document.cookie = `${key}=${value};Path=/;SameSite=Lax` + const pathBits = window.location.pathname.split('/') + const path = pathBits.slice(0, pathBits.length - 1).concat('/') + document.cookie = `${key}=${value};Path=${path};SameSite=Lax` }, removeItem(key) { if (typeof window === 'undefined') return