diff --git a/app/api/caddy/routes/[route]/route.ts b/app/api/caddy/routes/[route]/route.ts index 70bae3d..32bce88 100644 --- a/app/api/caddy/routes/[route]/route.ts +++ b/app/api/caddy/routes/[route]/route.ts @@ -4,7 +4,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request, { params }: { params: { route: number } }) { const slug = params.route; - const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/${slug}`, { cache: 'no-store' }); + const res = await fetch(`${process.env.CADDY_API}/config/apps/http/servers/srv0/routes/${slug}`, { cache: 'no-store' }); let route: Route = await res.json(); if (!res.ok) return onError('Failed to get route'); @@ -44,7 +44,7 @@ export async function PUT(request: Request, { params }: { params: { route: numbe const slug = params.route; let route: Route = await request.json(); - const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/${slug}`, { + const res = await fetch(`${process.env.CADDY_API}/config/apps/http/servers/srv0/routes/${slug}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' diff --git a/app/api/caddy/routes/route.ts b/app/api/caddy/routes/route.ts index 7caadd2..bebf8a3 100644 --- a/app/api/caddy/routes/route.ts +++ b/app/api/caddy/routes/route.ts @@ -38,7 +38,7 @@ export async function DELETE(req: Request) { }, }) - const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/${index}`, { + const res = await fetch(`${process.env.CADDY_API}/config/apps/http/servers/srv0/routes/${index}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' diff --git a/app/api/caddy/servers/route.ts b/app/api/caddy/servers/route.ts index 35464b3..0d088e2 100644 --- a/app/api/caddy/servers/route.ts +++ b/app/api/caddy/servers/route.ts @@ -1,7 +1,7 @@ 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' }); + const res = await fetch(`${process.env.CADDY_API}/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.'); diff --git a/lib/clientActions.ts b/lib/clientActions.ts index 9d64073..99b1ad3 100644 --- a/lib/clientActions.ts +++ b/lib/clientActions.ts @@ -19,7 +19,7 @@ export async function useConfig() { } export async function useUpstreamRoutes(route: Route) { - const { data, error, isLoading } = useSWR('http://192.168.1.69:2019/reverse_proxy/upstreams', fetcher); + const { data, error, isLoading } = useSWR(`${process.env.CADDY_API}/reverse_proxy/upstreams`, fetcher); return { data, error, diff --git a/lib/serverActions.ts b/lib/serverActions.ts index 618f558..ba41dc4 100644 --- a/lib/serverActions.ts +++ b/lib/serverActions.ts @@ -1,7 +1,7 @@ 'use server'; export async function getConfig() { - const res = await fetch('http://192.168.1.69:2019/config/', { + const res = await fetch(`${process.env.CADDY_API}/config/`, { cache: 'no-cache', }).catch(() => { throw new Error('Failed to fetch caddy config. Please check the network and try again.'); @@ -13,7 +13,7 @@ } export async function getServer() { - const res = await fetch('http://localhost:3000/api/caddy/servers').catch(() => { + const res = await fetch(`${process.env.URL}/api/caddy/servers`).catch(() => { throw new Error('Failed to fetch caddy servers. Please check the network and try again.'); }); @@ -33,7 +33,7 @@ } export async function getUpstreamRequests(route: Route) { - let upstreams: UpstreamRequest[] = await fetch(`http://192.168.1.69:2019/reverse_proxy/upstreams`, { + let upstreams: UpstreamRequest[] = await fetch(`${process.env.CADDY_API}/reverse_proxy/upstreams`, { headers: { 'Content-Type': 'application/json' }, @@ -45,7 +45,7 @@ } export async function getRoutes() { - let res = await fetch('http://localhost:3000/api/caddy/routes', { cache: 'no-cache' }).catch(() => { + let res = await fetch(`${process.env.URL}/api/caddy/routes`, { cache: 'no-cache' }).catch(() => { throw new Error('Failed to fetch routes. Please check the network and try again.'); }); diff --git a/next.config.js b/next.config.js index 767719f..9e65efb 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,6 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {} +const nextConfig = { + output: "standalone" +} module.exports = nextConfig