feat: add console link next to VM/LXC names

Clicking the name opens the Proxmox web console in a new tab.
URLs are constructed in the API routes using the configured PROXMOX_API_URL.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-07 10:22:29 +01:00
parent d5e85ce3c1
commit 7baf6a50fa
4 changed files with 80 additions and 6 deletions

View File

@@ -1,6 +1,9 @@
import { NextResponse } from 'next/server';
import { getNodes, getVMs } from '@/lib/proxmox';
const PROXMOX_API_URL = process.env.PROXMOX_API_URL || 'https://proxmox:8006/api2/json';
const PROXMOX_WEBUI = PROXMOX_API_URL.replace('/api2/json', '');
/** @param {import('next').Request} _req */
export async function GET(_req) {
try {
@@ -10,7 +13,13 @@ export async function GET(_req) {
for (const node of nodes) {
try {
const vms = await getVMs(node.name);
allVMs.push(...vms.map((vm) => ({ ...vm, node: node.name })));
allVMs.push(
...vms.map((vm) => ({
...vm,
node: node.name,
consoleUrl: `${PROXMOX_WEBUI}/pve/console?node=${encodeURIComponent(node.name)}&vmid=${vm.vmid}`,
})),
);
} catch { /* skip node */ }
}