Started working on route removal

This commit is contained in:
brian 2023-11-15 01:46:12 -05:00
parent f8c49b1bc5
commit fc9d16fa72
2 changed files with 37 additions and 0 deletions

View file

@ -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',
},
});
}

View file

@ -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',
},
});
}