From 5e1d290865876a7e002b1e6c3c2911e1ac7e49b2 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sat, 20 Dec 2025 18:18:11 -0500 Subject: [PATCH 1/2] 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'); }); }); }); From 116b6a15b0bf7db3a11fb428706dde126814004d Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sat, 20 Dec 2025 18:31:59 -0500 Subject: [PATCH 2/2] feat(proxy): improve remote proxy UX defaults - Change HTTP default port from 80 to 8317 (CLIProxyAPI default) - Keep HTTPS default at 443 (standard SSL behind reverse proxy) - Hide Local Proxy section when in Remote mode to reduce confusion --- src/cliproxy/remote-proxy-client.ts | 3 +- ui/src/pages/settings.tsx | 69 +++++++++++++++-------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/cliproxy/remote-proxy-client.ts b/src/cliproxy/remote-proxy-client.ts index c8a8d8f5..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; } /** 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 */} -
-

Local Proxy

-
- {/* Port */} -
- - setEditedLocalPort(e.target.value)} - onBlur={saveLocalPort} - placeholder="8317" - className="font-mono max-w-32" - disabled={saving} - /> -
+ {/* Local Proxy Settings - Only show in Local mode */} + {!isRemoteMode && ( +
+

Local Proxy

+
+ {/* Port */} +
+ + setEditedLocalPort(e.target.value)} + onBlur={saveLocalPort} + placeholder="8317" + className="font-mono max-w-32" + disabled={saving} + /> +
- {/* Auto-start */} -
-
-

Auto-start

-

- Start local proxy automatically when needed -

+ {/* Auto-start */} +
+
+

Auto-start

+

+ Start local proxy automatically when needed +

+
+ + saveCliproxyServerConfig({ local: { ...localConfig, auto_start: checked } }) + } + disabled={saving} + />
- - saveCliproxyServerConfig({ local: { ...localConfig, auto_start: checked } }) - } - disabled={saving} - />
-
+ )}