From 2bc068a74a1922d7a2a710deba3c229c6db5e5ba Mon Sep 17 00:00:00 2001 From: Devin Date: Sun, 21 Sep 2025 08:50:10 -0700 Subject: [PATCH] fix: #45 Add HTTP proxy support Signed-off-by: Devin --- lib/releases.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/releases.js b/lib/releases.js index a7eb082..b001dbc 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -28,21 +28,26 @@ class Release { * @return {Array} Releases. */ async function fetchReleases (githubToken) { + const hc = require('@actions/http-client'); + const userAgent = 'opentofu/setup-opentofu'; + + const http = new hc.HttpClient(userAgent); + const url = 'https://get.opentofu.org/tofu/api.json'; const headers = { Accept: 'application/json' }; - const resp = await fetch(url, { - headers - }); + const resp = await http.get(url, headers); - if (!resp.ok) { - throw new Error('failed fetching releases (' + resp.status + ')'); + if (resp.message.statusCode !== 200) { + throw new Error('failed fetching releases (' + resp.message.statusCode + ')'); } + + body = await resp.readBody(); + const releasesMeta = JSON.parse(body); - const releasesMeta = await resp.json(); /** * @type {Array} */