Skip to content

Commit 2f23d56

Browse files
committed
addressed commet
1 parent 75f8e8c commit 2f23d56

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/helpers/apiEndpoint.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export function getRegionSubdomain(region?: string): string {
6666

6767
/**
6868
* Builds the `/v1` API base URL (protocol + host + `/v1`).
69-
* When `isMultiRegion` is true, strips any known region prefix from the host, then prepends the requested region.
69+
* When `isMultiRegion` is true and a region is selected, strips any known region prefix from the host,
70+
* then prepends that region. If multi-region is on but no region is requested (`region` missing or
71+
* unknown), the hostname is left unchanged so a default region baked into `APPWRITE_ENDPOINT` is kept.
7072
*/
7173
export function buildRegionalV1Endpoint(
7274
protocol: string,
@@ -78,8 +80,11 @@ export function buildRegionalV1Endpoint(
7880
return `${protocol}//${hostname}/v1`;
7981
}
8082

81-
const hostWithoutRegion = stripLeadingRegionSubdomain(hostname);
8283
const subdomain = getRegionSubdomain(region);
84+
if (!subdomain) {
85+
return `${protocol}//${hostname}/v1`;
86+
}
8387

88+
const hostWithoutRegion = stripLeadingRegionSubdomain(hostname);
8489
return `${protocol}//${subdomain}${hostWithoutRegion}/v1`;
8590
}

0 commit comments

Comments
 (0)