From 1a7f47522018d4a205fb0e38f3aaa34ec5eaf025 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 23 Oct 2024 22:51:04 +0900 Subject: [PATCH] make prod domains configurable --- .../accelerate-checkout/accelerate-checkout.component.ts | 9 ++------- frontend/src/app/services/state.service.ts | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts index e41fdc13e..9d2d2ad46 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts @@ -84,13 +84,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { timePaid: number = 0; // time acceleration requested math = Math; isMobile: boolean = window.innerWidth <= 767.98; - isProdDomain = ['mempool.space', - 'mempool-staging.va1.mempool.space', - 'mempool-staging.fmt.mempool.space', - 'mempool-staging.fra.mempool.space', - 'mempool-staging.tk7.mempool.space', - 'mempool-staging.sg1.mempool.space' - ].indexOf(document.location.hostname) > -1; + isProdDomain = false; private _step: CheckoutStep = 'summary'; simpleMode: boolean = true; @@ -143,6 +137,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { private authService: AuthServiceMempool, private enterpriseService: EnterpriseService, ) { + this.isProdDomain = this.stateService.env.PROD_DOMAINS.indexOf(document.location.hostname) > -1; this.accelerationUUID = insecureRandomUUID(); // Check if Apple Pay available diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 21c865f04..8dd17cf75 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -78,6 +78,7 @@ export interface Env { PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string; SERVICES_API?: string; customize?: Customization; + PROD_DOMAINS: string[]; } const defaultEnv: Env = { @@ -113,6 +114,7 @@ const defaultEnv: Env = { 'PUBLIC_ACCELERATIONS': false, 'ADDITIONAL_CURRENCIES': false, 'SERVICES_API': 'https://mempool.space/api/v1/services', + 'PROD_DOMAINS': [], }; @Injectable({ @@ -206,6 +208,10 @@ export class StateService { const browserWindow = window || {}; // @ts-ignore const browserWindowEnv = browserWindow.__env || {}; + if (browserWindowEnv.PROD_DOMAINS && typeof(browserWindowEnv.PROD_DOMAINS) === 'string') { + browserWindowEnv.PROD_DOMAINS = browserWindowEnv.PROD_DOMAINS.split(','); + } + this.env = Object.assign(defaultEnv, browserWindowEnv); if (defaultEnv.BASE_MODULE !== 'mempool') {