Skip to content

Commit 9c0d24b

Browse files
authored
fix(ab env): check the current host to determine the env (codesandbox#5933)
* fix(ab env): check the current host to determine the env * fix(ab env): use staging_branch to check the env * fix(ab env): use staging env to determine the env * fix(ab env): check the current node env and staging * fix(ab env): reuse sse logic * fix(abenv): cover local cases * fix(ab env): recreate host func * fix(env): remove unnecessary stringify in the ab testing env * feat(ab env): check the current url
1 parent 2c2df9c commit 9c0d24b

File tree

1 file changed

+5
-3
lines changed
  • packages/common/src/config

1 file changed

+5
-3
lines changed

packages/common/src/config/env.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ const STAGING_API = Boolean(JSON.stringify(process.env.STAGING_API));
1010

1111
const AB_TESTING_URL_STAGING = 'https://ab-testing.codesandbox.stream';
1212
const AB_TESTING_URL_PRODUCTION = 'https://ab-testing.codesandbox.io';
13-
export const AB_TESTING_URL = STAGING_API
14-
? AB_TESTING_URL_STAGING
15-
: AB_TESTING_URL_PRODUCTION;
13+
export const AB_TESTING_URL = /codesandbox\.io/.test(
14+
typeof window !== `undefined` ? window?.location?.host : ''
15+
)
16+
? AB_TESTING_URL_PRODUCTION
17+
: AB_TESTING_URL_STAGING;
1618

1719
export const getExperimentUserId = () => {
1820
const KEY_NAME = 'csb-ab-user-id';

0 commit comments

Comments
 (0)