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 6b61c3240a
commit 77b067ea35
4 changed files with 80 additions and 6 deletions

View File

@@ -1,6 +1,9 @@
import { NextResponse } from 'next/server';
import { getNodes, getLXC } 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 lxcs = await getLXC(node.name);
allLXC.push(...lxcs.map((lxc) => ({ ...lxc, node: node.name })));
allLXC.push(
...lxcs.map((lxc) => ({
...lxc,
node: node.name,
consoleUrl: `${PROXMOX_WEBUI}/pve/console?node=${encodeURIComponent(node.name)}&vmid=${lxc.vmid}`,
})),
);
} catch { /* skip node */ }
}