Files
ProxMenux/AppImage/app/api/vms/route.ts

32 lines
903 B
TypeScript
Raw Normal View History

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/vms 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/vms", {
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 vmData = await response.json()
console.log("[v0] Successfully fetched real VM data from Flask:", vmData)
2025-09-29 17:21:59 +02:00
2025-09-29 17:57:00 +02:00
return NextResponse.json(vmData)
2025-09-29 17:21:59 +02:00
} catch (error) {
2025-09-29 17:57:00 +02:00
console.error("[v0] Failed to fetch VM data from Flask server:", error)
2025-09-29 17:21:59 +02:00
2025-09-29 17:57:00 +02:00
const fallbackData = []
2025-09-29 17:21:59 +02:00
console.log("[v0] Returning fallback VM data:", fallbackData)
2025-09-29 17:57:00 +02:00
return NextResponse.json(fallbackData, { status: 503 })
2025-09-29 17:21:59 +02:00
}
}