Fix regression, BACKEND_URL now only processed at request-time

Former-commit-id: da14f44e910786e9e21b5968b77e97a94f2876ab
This commit is contained in:
David Parry
2026-03-12 11:18:23 +11:00
parent c986de9e35
commit 40e89ac30b
4 changed files with 25 additions and 16 deletions
+16
View File
@@ -0,0 +1,16 @@
{
"permissions": {
"allow": [
"Bash(git checkout:*)",
"Bash(git add:*)",
"WebFetch(domain:localhost)",
"Bash(curl -s http://localhost:8000/api/settings/api-keys | head -50)",
"Bash(docker ps:*)",
"Bash(docker compose:*)",
"Bash(sleep 3 && curl -s http://localhost:3000/api/settings/api-keys | head -c 200)",
"Bash(sleep 4 && curl -s http://localhost:3000/api/settings/api-keys | head -c 200)",
"Bash(git commit:*)",
"WebSearch"
]
}
}
+5
View File
@@ -0,0 +1,5 @@
[env]
AIS_API_KEY="***REMOVED***"
OPENSKY_CLIENT_ID="***REMOVED***"
OPENSKY_CLIENT_SECRET="***REMOVED***"
BACKEND_URL="http://localhost:8000"
-4
View File
@@ -11,10 +11,6 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED 1
# NEXT_PUBLIC_* vars must exist at build time for Next.js to inline them.
# Default empty = auto-detect from browser hostname at runtime.
ARG NEXT_PUBLIC_API_URL=""
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build
FROM base AS runner
+4 -12
View File
@@ -1,9 +1,9 @@
import type { NextConfig } from "next";
// BACKEND_URL is a plain (non-NEXT_PUBLIC_) env var read at server startup —
// not baked at build time — so it can be set in docker-compose `environment`.
// Defaults to localhost for local dev where both services run on the same host.
const backendUrl = process.env.BACKEND_URL ?? "http://localhost:8000";
// /api/* requests are proxied to the backend by the catch-all route handler at
// src/app/api/[...path]/route.ts, which reads BACKEND_URL at request time.
// Do NOT add rewrites for /api/* here — next.config is evaluated at build time,
// so any URL baked in here ignores the runtime BACKEND_URL env var.
const nextConfig: NextConfig = {
transpilePackages: ['react-map-gl', 'mapbox-gl', 'maplibre-gl'],
@@ -14,14 +14,6 @@ const nextConfig: NextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${backendUrl}/api/:path*`,
},
];
},
};
export default nextConfig;