Remote connection
This commit is contained in:
@@ -70,7 +70,13 @@ export class ServerDirectoryService {
|
||||
|
||||
private get baseUrl(): string {
|
||||
const active = this.activeServer();
|
||||
return active ? `${active.url}/api` : 'http://localhost:3001/api';
|
||||
const raw = active ? active.url : 'http://localhost:3001';
|
||||
// Strip trailing slashes and any accidental '/api'
|
||||
let base = raw.replace(/\/+$/,'');
|
||||
if (base.toLowerCase().endsWith('/api')) {
|
||||
base = base.slice(0, -4);
|
||||
}
|
||||
return `${base}/api`;
|
||||
}
|
||||
|
||||
// Expose API base URL for consumers that need to call server endpoints
|
||||
@@ -83,7 +89,13 @@ export class ServerDirectoryService {
|
||||
const newServer: ServerEndpoint = {
|
||||
id: crypto.randomUUID(),
|
||||
name: server.name,
|
||||
url: server.url.replace(/\/$/, ''), // Remove trailing slash
|
||||
// Sanitize: remove trailing slashes and any '/api'
|
||||
url: (() => {
|
||||
let u = server.url.trim();
|
||||
u = u.replace(/\/+$/,'');
|
||||
if (u.toLowerCase().endsWith('/api')) u = u.slice(0, -4);
|
||||
return u;
|
||||
})(),
|
||||
isActive: false,
|
||||
isDefault: false,
|
||||
status: 'unknown',
|
||||
|
||||
Reference in New Issue
Block a user