avoid duplicate region prefix in getApiEndpoint for regional API URLs

This commit is contained in:
Harsh Mahajan
2026-03-29 15:16:03 +05:30
parent 089ca52f12
commit d2e7e263fe
+4 -1
View File
@@ -54,7 +54,10 @@ export function getApiEndpoint(region?: string): string {
const hostname = url.host; // "hostname:port" (or just "hostname" if no port)
// If instance supports multi-region, add the region subdomain.
const subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : '';
let subdomain = isMultiRegionSupported(url) ? getSubdomain(region) : '';
if (subdomain && hostname.startsWith(subdomain)) {
subdomain = '';
}
return `${protocol}//${subdomain}${hostname}/v1`;
}