From 0031d5289a85bb8c4dd9db3355e267eae17eff23 Mon Sep 17 00:00:00 2001 From: hass-demacia <138226515+hass-demacia@users.noreply.github.com> Date: Mon, 20 Oct 2025 16:34:38 +0800 Subject: [PATCH 1/2] Add SERVER_BASE_URL to next.config.ts Expose SERVER_BASE_URL in the environment variables. --- next.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/next.config.ts b/next.config.ts index 539857b6..7a574bcb 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,6 +5,10 @@ const TARGET_SERVER_BASE_URL = process.env.SERVER_BASE_URL || 'http://localhost: const nextConfig: NextConfig = { /* config options here */ output: 'standalone', + /* expose SERVER_BASE_URL to bundle */ + env: { + SERVER_BASE_URL: TARGET_SERVER_BASE_URL, + }, // Optimize build for Docker experimental: { optimizePackageImports: ['@mermaid-js/mermaid', 'react-syntax-highlighter'], From 9bf711941e6626bfa3eba6d4236887e8ed286760 Mon Sep 17 00:00:00 2001 From: hass-demacia <138226515+hass-demacia@users.noreply.github.com> Date: Mon, 20 Oct 2025 16:41:13 +0800 Subject: [PATCH 2/2] Add SERVER_BASE_URL to Dockerfile Set SERVER_BASE_URL environment variable for client bundle. --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index ab818ef5..4cbb40a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ COPY public/ ./public/ # Increase Node.js memory limit for build and disable telemetry ENV NODE_OPTIONS="--max-old-space-size=4096" ENV NEXT_TELEMETRY_DISABLED=1 +# `next build` inject `SERVER_BASE_URL` into bundle.js for client, once code is builded, bundle can't be modify by .env or ENV parameters. +ENV SERVER_BASE_URL="http://localhost:${PORT:-8001}" RUN NODE_ENV=production npm run build FROM python:3.11-slim AS py_deps