From 8352a97f62fc74206a40965b5557293be3725f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tayfun=20Y=C4=B1lmaz?= Date: Mon, 3 Aug 2026 09:15:54 +0300 Subject: [PATCH] fix(api): restore User-Agent header on API requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The axios refactor in dc5211f dropped the USER_AGENT constant but left a reference to it in testApiConnection's headers. That threw a ReferenceError on every health check, which the surrounding catch swallowed into a plain `false` — so the connection test reported the API as unreachable even when it was up. Restore the constant and set it as a default header on the shared axios instance so all three calls (/health, publish, re-initialize) send it and it cannot be dropped piecemeal again. Co-Authored-By: Claude Opus 5 --- src/lib/api.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/api.js b/src/lib/api.js index 6692acc..3135080 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -1,13 +1,18 @@ const axios = require('axios'); const https = require('node:https'); const http = require('node:http'); +const pkg = require('../../package.json'); + +// Identifies requests as coming from the CLI (e.g. "vnext-workflow-cli/1.0.0") +const USER_AGENT = `vnext-workflow-cli/${pkg.version}`; // Create axios instance with custom agents for both HTTP and HTTPS const apiClient = axios.create({ httpAgent: new http.Agent({ keepAlive: true }), - httpsAgent: new https.Agent({ + httpsAgent: new https.Agent({ rejectUnauthorized: false // Allow self-signed certificates - }) + }), + headers: { 'User-Agent': USER_AGENT } }); /** @@ -18,8 +23,7 @@ const apiClient = axios.create({ async function testApiConnection(baseUrl) { try { const response = await apiClient.get(`${baseUrl}/health`, { - timeout: 5000, - headers: { 'User-Agent': USER_AGENT } + timeout: 5000 }); return response.status === 200; } catch (error) {