mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
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
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user