From 5e1d290865876a7e002b1e6c3c2911e1ac7e49b2 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sat, 20 Dec 2025 18:18:11 -0500 Subject: [PATCH] fix(cliproxy): use /v1/models for remote proxy health check CLIProxyAPI doesn't expose a /health endpoint, causing 404 errors when testing remote proxy connections. Changed to use /v1/models which is always available and returns 200 when operational. Fixes #142 --- src/cliproxy/remote-proxy-client.ts | 7 +++++-- tests/unit/cliproxy/remote-proxy-client.test.ts | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cliproxy/remote-proxy-client.ts b/src/cliproxy/remote-proxy-client.ts index 047ea356..c8a8d8f5 100644 --- a/src/cliproxy/remote-proxy-client.ts +++ b/src/cliproxy/remote-proxy-client.ts @@ -139,6 +139,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 +160,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'); }); }); });