Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cookie on dev domain #1365

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SparkMD5 from 'spark-md5'
import UniversalCookies from 'universal-cookie'
import {
ACCESS_TOKEN_COOKIE_KEY,
getCookieDomain,
OAuth2State,
SynapseConstants,
} from '../utils'
Expand Down Expand Up @@ -1974,6 +1975,7 @@ export const setAccessTokenCookie = async (
// expires in 10 days (see SWC-6190)
maxAge: 60 * 60 * 24 * 10,
path: '/',
domain: getCookieDomain(),
})
}
} else {
Expand Down
10 changes: 7 additions & 3 deletions packages/synapse-react-client/src/utils/AppUtils/AppUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading