2025-09-29 17:21:59 +02:00
|
|
|
import { type NextRequest, NextResponse } from "next/server"
|
|
|
|
|
|
|
|
export async function GET(request: NextRequest) {
|
2025-09-29 17:57:00 +02:00
|
|
|
console.log("[v0] API route /api/system-info called")
|
2025-09-29 17:21:59 +02:00
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
try {
|
|
|
|
const response = await fetch("http://localhost:8008/api/system-info", {
|
2025-09-29 17:21:59 +02:00
|
|
|
method: "GET",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
signal: AbortSignal.timeout(5000),
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
}
|
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
const systemInfo = await response.json()
|
|
|
|
console.log("[v0] Successfully fetched real system info from Flask:", systemInfo)
|
2025-09-29 17:21:59 +02:00
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
return NextResponse.json({
|
|
|
|
...systemInfo,
|
|
|
|
source: "flask",
|
|
|
|
})
|
2025-09-29 17:21:59 +02:00
|
|
|
} catch (error) {
|
2025-09-29 17:57:00 +02:00
|
|
|
console.error("[v0] Failed to fetch system info from Flask server:", error)
|
2025-09-29 17:21:59 +02:00
|
|
|
|
|
|
|
const fallbackData = {
|
2025-09-29 17:57:00 +02:00
|
|
|
hostname: "proxmox-server",
|
|
|
|
node_id: "pve-node",
|
|
|
|
pve_version: "PVE Unknown",
|
|
|
|
status: "offline",
|
2025-09-29 17:21:59 +02:00
|
|
|
timestamp: new Date().toISOString(),
|
|
|
|
source: "fallback",
|
2025-09-29 17:57:00 +02:00
|
|
|
error: "Flask server unavailable",
|
2025-09-29 17:21:59 +02:00
|
|
|
}
|
|
|
|
|
2025-09-29 17:57:00 +02:00
|
|
|
console.log("[v0] Returning fallback system info:", fallbackData)
|
|
|
|
return NextResponse.json(fallbackData, { status: 503 })
|
2025-09-29 17:21:59 +02:00
|
|
|
}
|
|
|
|
}
|