import { NextResponse } from 'next/server'; import { getVMList } from '@/lib/ssh'; export async function GET() { try { console.log('[API] Fetching VM list...'); const vms = await getVMList(); console.log('[API] VMs fetched successfully:', vms.length); return NextResponse.json({ vms }); } catch (error) { console.error('[API] Error fetching VMs:', error); console.error('[API] Error stack:', error instanceof Error ? error.stack : 'No stack trace'); return NextResponse.json( { error: 'Failed to fetch VMs', details: error instanceof Error ? error.message : String(error) }, { status: 500 } ); } }