fix: backend url normalization
This commit is contained in:
@@ -29,8 +29,13 @@ const ACTIVE_KEY = 'mcma:activeInstance';
|
||||
const LEGACY_URL_KEY = 'mcma_api_base_url';
|
||||
const LEGACY_AUTH_KEY = 'mcma_auth';
|
||||
|
||||
// The UI always talks to the `/api/v1` contract, so users only enter the
|
||||
// origin (and optional reverse-proxy prefix). We append the contract path
|
||||
// here, the single choke point for both the base URL and the instance id, so
|
||||
// `domain.com`, `domain.com/`, and `domain.com/api/v1` all converge.
|
||||
function normalizeUrl(url: string): string {
|
||||
return url.trim().replace(/\/+$/, '');
|
||||
const trimmed = url.trim().replace(/\/+$/, '');
|
||||
return /\/api\/v1$/.test(trimmed) ? trimmed : `${trimmed}/api/v1`;
|
||||
}
|
||||
|
||||
/** Stable, readable id from a base URL — also serves as the storage namespace. */
|
||||
|
||||
Reference in New Issue
Block a user