addressed commet

This commit is contained in:
harsh mahajan
2026-04-16 15:56:10 +05:30
parent 75f8e8c04a
commit 2f23d5625c
+7 -2
View File
@@ -66,7 +66,9 @@ export function getRegionSubdomain(region?: string): string {
/**
* Builds the `/v1` API base URL (protocol + host + `/v1`).
* When `isMultiRegion` is true, strips any known region prefix from the host, then prepends the requested region.
* When `isMultiRegion` is true and a region is selected, strips any known region prefix from the host,
* then prepends that region. If multi-region is on but no region is requested (`region` missing or
* unknown), the hostname is left unchanged so a default region baked into `APPWRITE_ENDPOINT` is kept.
*/
export function buildRegionalV1Endpoint(
protocol: string,
@@ -78,8 +80,11 @@ export function buildRegionalV1Endpoint(
return `${protocol}//${hostname}/v1`;
}
const hostWithoutRegion = stripLeadingRegionSubdomain(hostname);
const subdomain = getRegionSubdomain(region);
if (!subdomain) {
return `${protocol}//${hostname}/v1`;
}
const hostWithoutRegion = stripLeadingRegionSubdomain(hostname);
return `${protocol}//${subdomain}${hostWithoutRegion}/v1`;
}