diff --git a/app/api/caddy/servers/[server]/route.ts b/app/api/caddy/servers/[server]/route.ts new file mode 100644 index 0000000..98724aa --- /dev/null +++ b/app/api/caddy/servers/[server]/route.ts @@ -0,0 +1,19 @@ +import { getServer } from "@/lib/utils"; +import { NextResponse } from "next/server"; + +export async function GET(request: Request, {params}: {params: {server: string}}) { + const slug = params.server; + const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/${slug}`, { cache: 'no-store' }); + + if (!res.ok) + throw new Error('Failed to fetch caddy config. Please check the network and try again.'); + + let server: Server = await res.json(); + + return new NextResponse(JSON.stringify(server), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); +} \ No newline at end of file diff --git a/app/api/caddy/servers/route.ts b/app/api/caddy/servers/route.ts new file mode 100644 index 0000000..8754eb9 --- /dev/null +++ b/app/api/caddy/servers/route.ts @@ -0,0 +1,18 @@ +import { getServer } from "@/lib/utils"; +import { NextResponse } from "next/server"; + +export async function GET(request: Request) { + const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/`, { cache: 'no-store' }); + + if (!res.ok) + throw new Error('Failed to fetch caddy config. Please check the network and try again.'); + + let servers: Server = await res.json(); + + return new NextResponse(JSON.stringify([servers]), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); +} \ No newline at end of file