diff --git a/src/cliproxy/remote-proxy-client.ts b/src/cliproxy/remote-proxy-client.ts index 047ea356..7bc3d3a3 100644 --- a/src/cliproxy/remote-proxy-client.ts +++ b/src/cliproxy/remote-proxy-client.ts @@ -48,9 +48,10 @@ const DEFAULT_TIMEOUT_MS = 2000; /** * Get default port for protocol + * HTTP defaults to 8317 (CLIProxyAPI default), HTTPS to 443 (standard SSL) */ function getDefaultPort(protocol: 'http' | 'https'): number { - return protocol === 'https' ? 443 : 80; + return protocol === 'https' ? 443 : 8317; } /** @@ -139,6 +140,9 @@ function createHttpsAgent(allowSelfSigned: boolean): https.Agent | undefined { /** * Check health of remote CLIProxyAPI instance * + * Uses /v1/models endpoint for health check since CLIProxyAPI doesn't expose /health. + * This endpoint is always available and returns 200 when the server is operational. + * * @param config Remote proxy client configuration * @returns RemoteProxyStatus with reachability and latency */ @@ -157,8 +161,8 @@ export async function checkRemoteProxy( }; } - // Use smart URL building - omit port if it's the default for the protocol - const url = buildProxyUrl(host, port, protocol, '/health'); + // Use /v1/models as health check - CLIProxyAPI doesn't have /health endpoint + const url = buildProxyUrl(host, port, protocol, '/v1/models'); const startTime = Date.now(); try { diff --git a/tests/unit/cliproxy/remote-proxy-client.test.ts b/tests/unit/cliproxy/remote-proxy-client.test.ts index 61022c11..3e7b95c8 100644 --- a/tests/unit/cliproxy/remote-proxy-client.test.ts +++ b/tests/unit/cliproxy/remote-proxy-client.test.ts @@ -105,14 +105,15 @@ describe('remote-proxy-client', () => { }); describe('health check URL construction', () => { - it('should construct correct health check URL pattern', () => { + // CLIProxyAPI uses /v1/models for health checks (no /health endpoint) + it('should construct correct health check URL pattern using /v1/models', () => { const config: RemoteProxyClientConfig = { host: '192.168.1.100', port: 8317, protocol: 'http', }; - const expectedUrl = `${config.protocol}://${config.host}:${config.port}/health`; - expect(expectedUrl).toBe('http://192.168.1.100:8317/health'); + const expectedUrl = `${config.protocol}://${config.host}:${config.port}/v1/models`; + expect(expectedUrl).toBe('http://192.168.1.100:8317/v1/models'); }); it('should construct HTTPS URL when protocol is https', () => { @@ -121,8 +122,8 @@ describe('remote-proxy-client', () => { port: 443, protocol: 'https', }; - const expectedUrl = `${config.protocol}://${config.host}:${config.port}/health`; - expect(expectedUrl).toBe('https://secure.example.com:443/health'); + const expectedUrl = `${config.protocol}://${config.host}:${config.port}/v1/models`; + expect(expectedUrl).toBe('https://secure.example.com:443/v1/models'); }); }); }); diff --git a/ui/src/pages/settings.tsx b/ui/src/pages/settings.tsx index 07fdce31..235614e0 100644 --- a/ui/src/pages/settings.tsx +++ b/ui/src/pages/settings.tsx @@ -1322,7 +1322,8 @@ function ProxyContent({ const defaultLocal = { port: 8317, auto_start: true }; // Helper to get default port based on protocol - const getDefaultPort = (protocol: 'http' | 'https') => (protocol === 'https' ? 443 : 80); + // HTTP defaults to 8317 (CLIProxyAPI default), HTTPS to 443 (standard SSL) + const getDefaultPort = (protocol: 'http' | 'https') => (protocol === 'https' ? 443 : 8317); // Sync local state with config (using refs to avoid lint warnings) const hostInput = config?.remote.host ?? ''; @@ -1650,42 +1651,44 @@ function ProxyContent({ - {/* Local Proxy Settings */} -
Auto-start
-- Start local proxy automatically when needed -
+ {/* Auto-start */} +Auto-start
++ Start local proxy automatically when needed +
+