Refactored UI endpoint usage
This commit is contained in:
@@ -65,13 +65,33 @@ function pickFirstNonEmpty(...candidates: any[]): string | undefined {
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes an API base URL ensuring proper protocol and single trailing slash.
|
||||
* Normalizes an API base URL ensuring HTTPS protocol by default and a single trailing slash.
|
||||
*/
|
||||
function normalizeBaseUrl(url: string): string {
|
||||
const trimmed = url.trim();
|
||||
let trimmed = url.trim();
|
||||
// Ensure HTTPS is default protocol if protocol is omitted
|
||||
if (!/^https?:\/\//i.test(trimmed)) {
|
||||
trimmed = `https://${trimmed}`;
|
||||
} else if (trimmed.startsWith('http://') && !trimmed.includes('localhost') && !trimmed.includes('127.0.0.1')) {
|
||||
// Upgrade remote HTTP URLs to HTTPS by default
|
||||
trimmed = trimmed.replace(/^http:\/\//i, 'https://');
|
||||
}
|
||||
return trimmed.endsWith('/') ? trimmed : `${trimmed}/`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes an OIDC/STS Authority URL ensuring HTTPS protocol by default.
|
||||
*/
|
||||
function normalizeAuthorityUrl(url: string): string {
|
||||
let trimmed = url.trim();
|
||||
if (!/^https?:\/\//i.test(trimmed)) {
|
||||
trimmed = `https://${trimmed}`;
|
||||
} else if (trimmed.startsWith('http://') && !trimmed.includes('localhost') && !trimmed.includes('127.0.0.1')) {
|
||||
trimmed = trimmed.replace(/^http:\/\//i, 'https://');
|
||||
}
|
||||
return trimmed.replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads any runtime config object injected into window.
|
||||
* Supports: window.__RUNTIME_CONFIG__, window.APP_CONFIG, window._env_
|
||||
@@ -268,7 +288,7 @@ function resolveConfig(fetchedJson?: Record<string, any>): AppConfig {
|
||||
|
||||
return {
|
||||
SecuritySettings: {
|
||||
Authority: authority,
|
||||
Authority: normalizeAuthorityUrl(authority),
|
||||
Audience: audience,
|
||||
ClientId: clientId,
|
||||
ClientSecret: clientSecret,
|
||||
|
||||
Reference in New Issue
Block a user