fix and update

This commit is contained in:
lendry
2026-06-29 15:02:01 +03:00
parent 0df7240dc8
commit 01e4917acf
10 changed files with 326 additions and 132 deletions

View File

@@ -7,16 +7,25 @@ function resolveBrowserApiBaseUrl(): string {
return configuredApiUrl;
}
try {
const configured = new URL(configuredApiUrl);
if (configured.hostname !== window.location.hostname) {
return API_ORIGIN_PROXY_PREFIX;
}
} catch {
// keep configured URL
if (configuredApiUrl.startsWith('/')) {
return configuredApiUrl.replace(/\/+$/, '') || API_ORIGIN_PROXY_PREFIX;
}
return configuredApiUrl;
try {
const configured = new URL(configuredApiUrl);
const sameHost =
configured.hostname === window.location.hostname &&
(configured.port || (configured.protocol === 'https:' ? '443' : '80')) ===
(window.location.port || (window.location.protocol === 'https:' ? '443' : '80'));
if (sameHost) {
return API_ORIGIN_PROXY_PREFIX;
}
return configuredApiUrl.replace(/\/+$/, '');
} catch {
return API_ORIGIN_PROXY_PREFIX;
}
}
function resolveBrowserWsBaseUrl(): string {