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_URL_KEY = 'mcma_api_base_url';
|
||||||
const LEGACY_AUTH_KEY = 'mcma_auth';
|
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 {
|
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. */
|
/** Stable, readable id from a base URL — also serves as the storage namespace. */
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export function ConnectPage() {
|
|||||||
<TextField
|
<TextField
|
||||||
value={apiUrl}
|
value={apiUrl}
|
||||||
onChange={(e) => setApiUrl(e.target.value)}
|
onChange={(e) => setApiUrl(e.target.value)}
|
||||||
placeholder="https://your-server.example.com/api/v1"
|
placeholder="https://your-server.example.com"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user