From bc8c3ef591e9b72ba534357358552247de3caec9 Mon Sep 17 00:00:00 2001 From: kyle-ssg Date: Tue, 3 Dec 2024 11:38:07 +0000 Subject: [PATCH] Adjust sdk url where api url is relative --- frontend/common/constants.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/common/constants.ts b/frontend/common/constants.ts index 3d7d69984e7f..53ab6c22f698 100644 --- a/frontend/common/constants.ts +++ b/frontend/common/constants.ts @@ -245,6 +245,7 @@ const Constants = { property: '', value: '', } as SegmentCondition, + defaultTagColor: '#3d4db6', environmentPermissions: (perm: string) => `To manage this feature you need the ${perm} permission for this environment.
Please contact a member of this environment who has administrator privileges.`, events: { @@ -441,10 +442,16 @@ const Constants = { 'TRAITS_ID': 150, }, }, - getFlagsmithSDKUrl: () => - Utils.isSaas() || Project.api.startsWith('https://api.flagsmith.com') + + getFlagsmithSDKUrl: () => { + const apiUrl = Project.api.startsWith('/') + ? `${document.location.origin}${Project.api}` + : Project.api + + return Utils.isSaas() || apiUrl.startsWith('https://api.flagsmith.com') ? Project.flagsmithClientEdgeAPI - : Project.api, + : apiUrl + }, getUpgradeUrl: (feature?: string) => { return Utils.isSaas() ? '/organisation-settings?tab=billing' @@ -458,7 +465,6 @@ const Constants = { }, isCustomFlagsmithUrl: () => Constants.getFlagsmithSDKUrl() !== 'https://edge.api.flagsmith.com/api/v1/', - defaultTagColor: '#3d4db6', modals: { 'PAYMENT': 'Payment Modal', },