Skip to content

Commit 00d9765

Browse files
authored
Merge pull request #2941 from appwrite/fix/api-endpoint-double-region-subdomain
fix: avoid duplicate region prefix in getApiEndpoint for regional API URLs
2 parents 089ca52 + d2e7e26 commit 00d9765

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib/stores/sdk.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export function getApiEndpoint(region?: string): string {
5454
const hostname = url.host; // "hostname:port" (or just "hostname" if no port)
5555

5656
// If instance supports multi-region, add the region subdomain.
57-
const subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : '';
57+
let subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : '';
58+
if (subdomain && hostname.startsWith(subdomain)) {
59+
subdomain = '';
60+
}
5861

5962
return `${protocol}//${subdomain}${hostname}/v1`;
6063
}

0 commit comments

Comments
 (0)