fix: Fixed api url on web
Chart Release / chart (push) Successful in 10s
Server Deploy / deploy (push) Successful in 7m37s

This commit is contained in:
2026-08-25 13:53:59 +00:00
parent 3e4ccc9720
commit 7a0a1953f6
14 changed files with 109 additions and 83 deletions
+16 -40
View File
@@ -1,11 +1,21 @@
import type { NextConfig } from "next";
// Read at runtime, not baked in. The rewrites below run in the Next server
// process, never in the browser, so this never needed the NEXT_PUBLIC_ prefix
// that pins a value into the image at build time. NEXT_PUBLIC_API_URL is still
// honoured so an existing deployment passing it keeps working.
const apiUrl = process.env.API_URL ?? process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8080";
/*
* This app proxies nothing.
*
* /api, /auth, /install, /update and /public are the Go server's, and routing
* them there is the reverse proxy's job — the same proxy that already
* terminates TLS in front of this process. Next used to rewrite them itself
* from an API_URL naming the control plane, which meant every deployment had
* two possible request paths for the same URL and one environment variable
* that silently broke a whole prefix when it named the wrong host: pointed at
* the marketing site, /public/status/... 404'd as a page that does not exist,
* indistinguishable from a status page that does not exist.
*
* Browser calls are same-origin and relative (see lib/api.ts), and the public
* status page's server-side fetch is made against the visitor's own host, so
* nothing in this app needs to know the control plane's address any more.
*/
const nextConfig: NextConfig = {
output: "standalone",
async redirects() {
@@ -22,40 +32,6 @@ const nextConfig: NextConfig = {
},
];
},
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${apiUrl}/api/:path*`,
},
{
source: "/auth/:path*",
destination: `${apiUrl}/auth/:path*`,
},
{
source: "/install",
destination: `${apiUrl}/install`,
},
{
source: "/install.ps1",
destination: `${apiUrl}/install.ps1`,
},
{
source: "/update",
destination: `${apiUrl}/update`,
},
{
source: "/update.ps1",
destination: `${apiUrl}/update.ps1`,
},
{
// The public status page refreshes itself in the browser, so
// the public prefix has to be proxied the same way /api is.
source: "/public/:path*",
destination: `${apiUrl}/public/:path*`,
},
];
},
};
export default nextConfig;