diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index 218297700..9b46263cf 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -1,4 +1,4 @@ -import { VARS } from '$lib/system'; +import { isMultiRegionSupported, VARS } from '$lib/system'; import { Account, Assistant, @@ -46,7 +46,7 @@ export function getApiEndpoint(region?: string): string { const hostname = url.hostname; // If instance supports multi-region, add the region subdomain. - const subdomain = VARS.APPWRITE_MULTI_REGION ? getSubdomain(region) : ''; + const subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : ''; return `${protocol}//${subdomain}${hostname}/v1`; } diff --git a/src/lib/system.ts b/src/lib/system.ts index 94912fb95..c93f4f4d7 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -10,8 +10,7 @@ export const VARS = { CONSOLE_MODE: (env.PUBLIC_CONSOLE_MODE as Mode) ?? undefined, APPWRITE_ENDPOINT: env.PUBLIC_APPWRITE_ENDPOINT ?? undefined, GROWTH_ENDPOINT: env.PUBLIC_GROWTH_ENDPOINT ?? undefined, - PUBLIC_STRIPE_KEY: env.PUBLIC_STRIPE_KEY ?? undefined, - APPWRITE_MULTI_REGION: env.PUBLIC_APPWRITE_MULTI_REGION === 'true' + PUBLIC_STRIPE_KEY: env.PUBLIC_STRIPE_KEY ?? undefined }; export const ENV = { @@ -29,5 +28,15 @@ export const isProd = ENV.PROD; export const hasStripePublicKey = !!VARS.PUBLIC_STRIPE_KEY; export const GRACE_PERIOD_OVERRIDE = false; -// start showing 1.7.x feats! + export const SHOW_INIT_FEATURES = true; + +export function isMultiRegionSupported(url: URL): boolean { + if (env.PUBLIC_APPWRITE_MULTI_REGION === 'true') return true; + + try { + return url.hostname.endsWith('cloud.appwrite.io'); + } catch { + return false; + } +}