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:
commit
ddee4b498d
1 changed files with 3 additions and 3 deletions
|
|
@ -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) => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue