From 90b8d04d71c78b8a120ac8cd091ea0936ba5bb6f Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Wed, 18 Feb 2026 03:06:44 +0700 Subject: [PATCH] refactor(cliproxy): use shared default port in management paths - replace 8317 literals with CLIPROXY_DEFAULT_PORT constant - keep http/https fallback behavior unchanged in runtime checks --- src/cliproxy/management-api-client.ts | 6 ++---- src/web-server/routes/cliproxy-stats-routes.ts | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cliproxy/management-api-client.ts b/src/cliproxy/management-api-client.ts index 26f9a6ae..f89713e1 100644 --- a/src/cliproxy/management-api-client.ts +++ b/src/cliproxy/management-api-client.ts @@ -16,13 +16,11 @@ import type { RemoteModelInfo, GetModelDefinitionsResponse, } from './management-api-types'; +import { CLIPROXY_DEFAULT_PORT } from './config/port-manager'; /** Default timeout for management operations (longer than health check) */ const DEFAULT_TIMEOUT_MS = 5000; -/** Default port for HTTP protocol */ -const DEFAULT_HTTP_PORT = 8317; - /** Default port for HTTPS protocol */ const DEFAULT_HTTPS_PORT = 443; @@ -33,7 +31,7 @@ function getEffectivePort(port: number | undefined, protocol: 'http' | 'https'): if (port !== undefined && Number.isInteger(port) && port > 0 && port <= 65535) { return port; } - return protocol === 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT; + return protocol === 'https' ? DEFAULT_HTTPS_PORT : CLIPROXY_DEFAULT_PORT; } /** diff --git a/src/web-server/routes/cliproxy-stats-routes.ts b/src/web-server/routes/cliproxy-stats-routes.ts index 4fd41249..e6c6e475 100644 --- a/src/web-server/routes/cliproxy-stats-routes.ts +++ b/src/web-server/routes/cliproxy-stats-routes.ts @@ -43,6 +43,7 @@ import { DEFAULT_BACKEND, } from '../../cliproxy/platform-detector'; import { loadOrCreateUnifiedConfig } from '../../config/unified-config-loader'; +import { CLIPROXY_DEFAULT_PORT } from '../../cliproxy/config/port-manager'; const router = Router(); @@ -208,7 +209,7 @@ router.get('/proxy-status', async (_req: Request, res: Response): Promise // Proxy running but no session lock - legacy/untracked instance res.json({ running: true, - port: 8317, // Default port + port: CLIPROXY_DEFAULT_PORT, sessionCount: 0, // Unknown sessions // No pid/startedAt since we don't have session lock });