diff --git a/src/renderer/src/cookies.ts b/src/renderer/src/cookies.ts index 66d046c3b..b769ed7f8 100644 --- a/src/renderer/src/cookies.ts +++ b/src/renderer/src/cookies.ts @@ -1,15 +1,17 @@ -export function addCookieInterceptor() { +export function addCookieInterceptor(isStaging: boolean) { + const cookieKey = isStaging ? "cookies-staging" : "cookies"; + Object.defineProperty(document, "cookie", { enumerable: true, configurable: true, get() { - return localStorage.getItem("cookies") || ""; + return localStorage.getItem(cookieKey) || ""; }, set(cookieString) { try { const [cookieName, cookieValue] = cookieString.split(";")[0].split("="); - const currentCookies = localStorage.getItem("cookies") || ""; + const currentCookies = localStorage.getItem(cookieKey) || ""; const cookiesObject = parseCookieStringsToObjects(currentCookies); cookiesObject[cookieName] = cookieValue; @@ -20,7 +22,7 @@ export function addCookieInterceptor() { }) .join("; "); - localStorage.setItem("cookies", newString); + localStorage.setItem(cookieKey, newString); } catch (err) { console.error(err); } diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index 8f729df9e..f2e326c36 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -38,7 +38,8 @@ const Achievements = React.lazy( console.log = logger.log; -addCookieInterceptor(); +const isStaging = await window.electron.isStaging(); +addCookieInterceptor(isStaging); i18n .use(LanguageDetector)