From acdff2fe7e3d60392f32e810e6ee47a963f982fb Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Mon, 11 Nov 2024 12:02:09 -0500 Subject: [PATCH] fix cookie on dev domain --- .../src/synapse-client/SynapseClient.ts | 2 ++ .../src/utils/AppUtils/AppUtils.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts index df047409b0..2640aa526f 100644 --- a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts +++ b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts @@ -3,6 +3,7 @@ import SparkMD5 from 'spark-md5' import UniversalCookies from 'universal-cookie' import { ACCESS_TOKEN_COOKIE_KEY, + getCookieDomain, OAuth2State, SynapseConstants, } from '../utils' @@ -1974,6 +1975,7 @@ export const setAccessTokenCookie = async ( // expires in 10 days (see SWC-6190) maxAge: 60 * 60 * 24 * 10, path: '/', + domain: getCookieDomain(), }) } } else { diff --git a/packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts b/packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts index d90cbfef0b..7ade44e4a3 100644 --- a/packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts +++ b/packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts @@ -15,9 +15,13 @@ export const ONE_SAGE_REDIRECT_COOKIE_KEY = 'org.sagebionetworks.cookies.redirect-after-login' export const getCookieDomain = () => { - return window.location.hostname.toLowerCase().endsWith('.synapse.org') - ? '.synapse.org' - : undefined + if (window.location.hostname.toLowerCase().endsWith('.synapse.org')) { + return '.synapse.org' + } + if (window.location.hostname.toLowerCase().endsWith('dev.sagebase.org')) { + return '.dev.sagebase.org' + } + return undefined } export function storeRedirectURLForOneSageLoginAndGotoURL(href: string) {