From f2c4267f37d18131b4fa377d7141c40d971fcced Mon Sep 17 00:00:00 2001 From: Filip Wachowiak Date: Sun, 21 Mar 2021 00:28:34 +0100 Subject: [PATCH] fix: Logout staging cookie, remove expires option on cookies --- .idea/vcs.xml | 6 ++++++ src/utils/setToken.ts | 1 - src/utils/unsetToken.ts | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..4c6280e 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,5 +1,11 @@ + + + + + + diff --git a/src/utils/setToken.ts b/src/utils/setToken.ts index 0f602f8..a236d7d 100644 --- a/src/utils/setToken.ts +++ b/src/utils/setToken.ts @@ -14,7 +14,6 @@ export async function setToken(token: string, setCookies: Array) { value: token, options: { domain: SERVER_HOST, - expires: new Date(Date.now() + MILLISECONDS_IN_A_WEEK), httpOnly: true, maxAge: MILLISECONDS_IN_A_WEEK / 100, path: "/", diff --git a/src/utils/unsetToken.ts b/src/utils/unsetToken.ts index b637945..5001ed1 100644 --- a/src/utils/unsetToken.ts +++ b/src/utils/unsetToken.ts @@ -12,11 +12,12 @@ export async function unsetToken(setCookies: Array) { value: "", options: { domain: SERVER_HOST, - expires: new Date(Date.now()), httpOnly: true, + // Set and max-age to unset the cookie in the browser maxAge: 0, path: "/", - sameSite: true, + // Disable sameSite to allow localhost development with staging backend + sameSite: STAGE === "staging" ? "none" : "strict", secure: STAGE !== "dev", }, });