Remote connection

This commit is contained in:
2026-01-09 19:49:38 +01:00
parent 87c722b5ae
commit 8c551a90f4
28 changed files with 3134 additions and 327 deletions

View File

@@ -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',