From 13fe8f0094acf678a8ccfb39d5a10dd713710a6e Mon Sep 17 00:00:00 2001 From: ReaJason Date: Sun, 30 Aug 2026 22:01:43 +0800 Subject: [PATCH] fix: vite8 preview build react-router in docker failed --- web/app/lib/config.tsx | 2 +- web/vite.config.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/app/lib/config.tsx b/web/app/lib/config.tsx index 718e1784..fc3dca56 100644 --- a/web/app/lib/config.tsx +++ b/web/app/lib/config.tsx @@ -1,6 +1,6 @@ -import { ExternalLinkIcon } from "lucide-react"; import type { LinkItemType } from "fumadocs-ui/layouts/shared"; +import { ExternalLinkIcon } from "lucide-react"; import { useTranslation } from "react-i18next"; import { LanguageSwitcher } from "@/components/language-switcher"; diff --git a/web/vite.config.ts b/web/vite.config.ts index b7bf6303..f27e4340 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -10,6 +10,9 @@ export default defineConfig(({ command, mode }) => { const contextPath = env.VITE_APP_API_URL?.trim() ?? ""; return { + // React Router 8 prerendering requests the Vite preview server over HTTP. + // Bind it explicitly to IPv4 so `localhost` resolves to the address being listened on in Docker. + preview: { host: "127.0.0.1" }, base: isDev || !contextPath ? "/" : `${contextPath}/`, plugins: [fumadocsMdx(), tailwindcss(), reactRouter(), devtoolsJson()], resolve: {