fix local bootstrap startup and catalog widget UX

This commit is contained in:
sdarbinyan
2026-07-05 02:44:04 +04:00
parent 487a3fb913
commit 145a13857d
10 changed files with 399 additions and 7 deletions

View File

@@ -19,12 +19,13 @@ export class ApiConfigService {
if (this.tenantResolver.isLocalhost() && localhostUrl) {
url = localhostUrl;
} else if (bootstrapUrl) {
url = bootstrapUrl;
} else if (tenantMap?.[tenantKey]) {
url = tenantMap[tenantKey];
} else if (apiTemplate) {
url = apiTemplate.replace('{tenant}', tenantKey);
} else if (bootstrapUrl) {
// Bootstrap API override is opt-in and only for absolute URLs.
url = bootstrapUrl;
}
return this.normalizeBaseUrl(url);
@@ -58,24 +59,33 @@ export class ApiConfigService {
}
private resolveBootstrapApiBaseUrl(): string | null {
const allowBootstrapApiOverride = (environment as any).allowBootstrapApiOverride === true;
if (!allowBootstrapApiOverride) {
return null;
}
const bootstrap = this.configService.getBootstrapSnapshot() as any;
if (!bootstrap) {
return null;
}
const endpointBase = bootstrap?.apiEndpoints?.website?.baseUrl;
if (typeof endpointBase === 'string' && endpointBase.trim().length > 0) {
if (typeof endpointBase === 'string' && this.isAbsoluteHttpUrl(endpointBase)) {
return endpointBase;
}
const tenantBase = bootstrap?.tenant?.apiBaseUrl;
if (typeof tenantBase === 'string' && tenantBase.trim().length > 0) {
if (typeof tenantBase === 'string' && this.isAbsoluteHttpUrl(tenantBase)) {
return tenantBase;
}
return null;
}
private isAbsoluteHttpUrl(url: string): boolean {
return /^https?:\/\//i.test(url.trim());
}
private normalizeBaseUrl(url: string): string {
if (!url || url === '/') {
return '/';