make prod domains configurable

This commit is contained in:
nymkappa 2024-10-23 22:51:04 +09:00
parent cb63d17a2f
commit 1a7f475220
No known key found for this signature in database
GPG Key ID: 92358FC85D9645DE
2 changed files with 8 additions and 7 deletions

View File

@ -84,13 +84,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
timePaid: number = 0; // time acceleration requested timePaid: number = 0; // time acceleration requested
math = Math; math = Math;
isMobile: boolean = window.innerWidth <= 767.98; isMobile: boolean = window.innerWidth <= 767.98;
isProdDomain = ['mempool.space', isProdDomain = false;
'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;
private _step: CheckoutStep = 'summary'; private _step: CheckoutStep = 'summary';
simpleMode: boolean = true; simpleMode: boolean = true;
@ -143,6 +137,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
private authService: AuthServiceMempool, private authService: AuthServiceMempool,
private enterpriseService: EnterpriseService, private enterpriseService: EnterpriseService,
) { ) {
this.isProdDomain = this.stateService.env.PROD_DOMAINS.indexOf(document.location.hostname) > -1;
this.accelerationUUID = insecureRandomUUID(); this.accelerationUUID = insecureRandomUUID();
// Check if Apple Pay available // Check if Apple Pay available

View File

@ -78,6 +78,7 @@ export interface Env {
PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string; PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string;
SERVICES_API?: string; SERVICES_API?: string;
customize?: Customization; customize?: Customization;
PROD_DOMAINS: string[];
} }
const defaultEnv: Env = { const defaultEnv: Env = {
@ -113,6 +114,7 @@ const defaultEnv: Env = {
'PUBLIC_ACCELERATIONS': false, 'PUBLIC_ACCELERATIONS': false,
'ADDITIONAL_CURRENCIES': false, 'ADDITIONAL_CURRENCIES': false,
'SERVICES_API': 'https://mempool.space/api/v1/services', 'SERVICES_API': 'https://mempool.space/api/v1/services',
'PROD_DOMAINS': [],
}; };
@Injectable({ @Injectable({
@ -206,6 +208,10 @@ export class StateService {
const browserWindow = window || {}; const browserWindow = window || {};
// @ts-ignore // @ts-ignore
const browserWindowEnv = browserWindow.__env || {}; 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); this.env = Object.assign(defaultEnv, browserWindowEnv);
if (defaultEnv.BASE_MODULE !== 'mempool') { if (defaultEnv.BASE_MODULE !== 'mempool') {