From: Adam Dullage Date: Sat, 14 Jun 2025 05:48:17 +0000 (+0100) Subject: #270 - Add base path to cookie string for correct path handling X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=bb747af0c038c4cb7a93cebdb04a2aaf086efbc4;p=flatnotes.git #270 - Add base path to cookie string for correct path handling --- diff --git a/client/tokenStorage.js b/client/tokenStorage.js index 959af4d..12c4e38 100644 --- a/client/tokenStorage.js +++ b/client/tokenStorage.js @@ -1,7 +1,13 @@ const tokenStorageKey = "token"; +function getBasePath() { + // This relies on the fact that flanotes always has a correctly formatted relative path set in tag + return document.querySelector('base').getAttribute('href') +} + function getCookieString(token) { - return `${tokenStorageKey}=${token}; SameSite=Strict`; + const basePath = getBasePath(); + return `${tokenStorageKey}=${token}; Path=${basePath}; SameSite=Strict`; } export function storeToken(token, persist = false) {