diff --git a/__tests__/Auth0Client/loginWithPopup.test.ts b/__tests__/Auth0Client/loginWithPopup.test.ts index 0dcef3eaa..f883ebb6a 100644 --- a/__tests__/Auth0Client/loginWithPopup.test.ts +++ b/__tests__/Auth0Client/loginWithPopup.test.ts @@ -682,7 +682,8 @@ describe('Auth0Client', () => { `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`, JSON.stringify(TEST_ORG_ID), { - expires: 1 + expires: 1, + domain: TEST_DOMAIN } ); @@ -702,11 +703,13 @@ describe('Auth0Client', () => { await loginWithPopup(auth0); expect(esCookie.remove).toHaveBeenCalledWith( - `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`, {} + `_legacy_auth0.${TEST_CLIENT_ID}.organization_hint`, + {} ); expect(esCookie.remove).toHaveBeenCalledWith( - `auth0.${TEST_CLIENT_ID}.organization_hint`, {} + `auth0.${TEST_CLIENT_ID}.organization_hint`, + {} ); }); diff --git a/__tests__/storage.test.ts b/__tests__/storage.test.ts index 092515420..1d92ddbdd 100644 --- a/__tests__/storage.test.ts +++ b/__tests__/storage.test.ts @@ -132,7 +132,8 @@ describe('CookieStorageWithLegacySameSite', () => { `_legacy_${key}`, JSON.stringify(value), { - expires: options.daysUntilExpire + expires: options.daysUntilExpire, + domain: options.cookieDomain } ); }); diff --git a/src/storage.ts b/src/storage.ts index 132f01ee9..1b4bb6f75 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -91,6 +91,10 @@ export const CookieStorageWithLegacySameSite = { cookieAttributes.expires = options.daysUntilExpire; } + if (options?.cookieDomain) { + cookieAttributes.domain = options.cookieDomain; + } + Cookies.set( `${LEGACY_PREFIX}${key}`, JSON.stringify(value),