/** @type {import('next').NextConfig} */ const apiBase = process.env.DY_INTERNAL_API_URL || "http://127.0.0.1:8014"; // Two production shapes share this file: // - VPS: Next + API on the same host; Caddy/nginx loopback to 127.0.0.1 // - Physical (PVE): Next + API on the LAN box; public Caddy is on the VPS and // reverse-proxies over WireGuard. Next still talks to API on 127.0.0.1. // Never rewrite `/covers` itself — that is the Next.js page. Rewriting it to // the FastAPI StaticFiles mount 302s the browser to http(s)://127.0.0.1:8014/covers/. const nextConfig = { async rewrites() { return [ { source: "/api/:path*", destination: `${apiBase}/api/:path*`, }, { source: "/covers/:path+", destination: `${apiBase}/covers/:path+`, }, // ShellCrash / mihomo dashboard (SH2-style web panel), local CrashCore :9999 { source: "/shellcrash-ui", destination: "http://127.0.0.1:9999/", }, { source: "/shellcrash-ui/:path*", destination: "http://127.0.0.1:9999/:path*", }, ]; }, }; export default nextConfig;