Started working on route removal
This commit is contained in:
parent
f8c49b1bc5
commit
fc9d16fa72
2 changed files with 37 additions and 0 deletions
19
app/api/caddy/servers/[server]/route.ts
Normal file
19
app/api/caddy/servers/[server]/route.ts
Normal 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',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
18
app/api/caddy/servers/route.ts
Normal file
18
app/api/caddy/servers/route.ts
Normal 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',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue