mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Fix isMultiRegionSupported to accept URL parameter
This commit is contained in:
@@ -42,7 +42,7 @@ export function getApiEndpoint(region?: string): string {
|
||||
const hostname = url.hostname;
|
||||
|
||||
// If instance supports multi-region, add the region subdomain.
|
||||
const subdomain = isMultiRegionSupported() ? getSubdomain(region) : '';
|
||||
const subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : '';
|
||||
|
||||
return `${protocol}//${subdomain}${hostname}/v1`;
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
import { env } from '$env/dynamic/public';
|
||||
import { dev } from '$app/environment';
|
||||
import { getApiEndpoint } from '$lib/stores/sdk';
|
||||
|
||||
export const enum Mode {
|
||||
CLOUD = 'cloud',
|
||||
@@ -32,11 +31,11 @@ export const GRACE_PERIOD_OVERRIDE = false;
|
||||
/**
|
||||
* Returns true if multi-region is supported.
|
||||
*/
|
||||
export function isMultiRegionSupported(): boolean {
|
||||
export function isMultiRegionSupported(url: URL): boolean {
|
||||
if (env.PUBLIC_APPWRITE_MULTI_REGION === 'true') return true;
|
||||
|
||||
try {
|
||||
return new URL(getApiEndpoint()).hostname.endsWith('cloud.appwrite.io');
|
||||
return url.hostname.endsWith('cloud.appwrite.io');
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user