fix(cliproxy): sanitize local port before config regeneration (#1342)

This commit is contained in:
Kai (Tam Nhu) Tran
2026-05-23 16:54:48 -04:00
committed by GitHub
parent fd561b59bc
commit af7aa0c2dd
+3 -2
View File
@@ -155,8 +155,9 @@ router.put('/backend', (req: Request, res: Response) => {
// Pre-flight read: check running state before acquiring write lock
const currentConfig = loadOrCreateUnifiedConfig();
const currentBackend = currentConfig.cliproxy?.backend ?? DEFAULT_BACKEND;
const localPort =
currentConfig.cliproxy_server?.local?.port ?? DEFAULT_CLIPROXY_SERVER_CONFIG.local.port;
const localPort = validatePort(
currentConfig.cliproxy_server?.local?.port ?? DEFAULT_CLIPROXY_SERVER_CONFIG.local.port
);
if (currentBackend !== backend && isProxyRunning() && !force) {
res.status(409).json({
error: 'Proxy is running. Stop proxy first or use force=true to change backend.',