import { redirect } from 'next/navigation' import Link from 'next/link' import { codeToHtml } from 'shiki' import { getCurrentUser } from '@/lib/session' import { execAgent } from '@/lib/agent-client' import { parseCertList, type CertInfo } from '@/lib/parse-caddy' import CaddyView from './_components/caddy-view' export const dynamic = 'force-dynamic' export default async function CaddyPage() { const user = await getCurrentUser() if (!user) redirect('/login') let configHtml = '' let configError: string | null = null try { const raw = await execAgent('caddy_show_config') configHtml = await codeToHtml(raw || '# (empty)', { lang: 'caddyfile', theme: 'github-dark', }) } catch (err) { configError = err instanceof Error ? err.message : 'failed' } let initialCerts: CertInfo[] = [] let certsError: string | null = null try { const raw = await execAgent('caddy_list_certs') initialCerts = parseCertList(raw) } catch (err) { certsError = err instanceof Error ? err.message : 'failed' } return (

Caddy

Config view and TLS certificate status

Caddyfile

Edit
{configError ? (
{configError}
) : (
)}
) }