Merge pull request #8 from SamuelSJames/claude/wonderful-faraday-qxym5t

Fix Proxmox connection by using undici's fetch instead of Node's global fetch
This commit is contained in:
Samuel James 2026-06-20 06:38:17 -04:00 committed by GitHub
commit ddee4b498d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
import { Agent } from 'undici' import { Agent, fetch } from 'undici'
import type { IntegrationAdapter, Resource } from './types.js' import type { IntegrationAdapter, Resource } from './types.js'
interface ProxmoxResourceEntry { interface ProxmoxResourceEntry {
@ -37,7 +37,7 @@ export const proxmox: IntegrationAdapter = {
const res = await fetch(`${baseUrl}/api2/json/version`, { const res = await fetch(`${baseUrl}/api2/json/version`, {
headers: authHeader(apiKey), headers: authHeader(apiKey),
dispatcher: insecureDispatcher, dispatcher: insecureDispatcher,
} as RequestInit) })
if (!res.ok) return { ok: false, message: `HTTP ${res.status}` } if (!res.ok) return { ok: false, message: `HTTP ${res.status}` }
return { ok: true, message: 'Connected' } return { ok: true, message: 'Connected' }
} catch (err) { } catch (err) {
@ -52,7 +52,7 @@ export const proxmox: IntegrationAdapter = {
const res = await fetch(`${baseUrl}/api2/json/cluster/resources?type=vm`, { const res = await fetch(`${baseUrl}/api2/json/cluster/resources?type=vm`, {
headers: authHeader(apiKey), headers: authHeader(apiKey),
dispatcher: insecureDispatcher, dispatcher: insecureDispatcher,
} as RequestInit) })
if (!res.ok) return [] if (!res.ok) return []
const body = (await res.json()) as { data: ProxmoxResourceEntry[] } const body = (await res.json()) as { data: ProxmoxResourceEntry[] }
return body.data.map((entry) => ({ return body.data.map((entry) => ({