fix: vite8 preview build react-router in docker failed

This commit is contained in:
ReaJason
2026-08-30 22:01:43 +08:00
parent 961845f96f
commit 13fe8f0094
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import { ExternalLinkIcon } from "lucide-react";
import type { LinkItemType } from "fumadocs-ui/layouts/shared"; import type { LinkItemType } from "fumadocs-ui/layouts/shared";
import { ExternalLinkIcon } from "lucide-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { LanguageSwitcher } from "@/components/language-switcher"; import { LanguageSwitcher } from "@/components/language-switcher";
+3
View File
@@ -10,6 +10,9 @@ export default defineConfig(({ command, mode }) => {
const contextPath = env.VITE_APP_API_URL?.trim() ?? ""; const contextPath = env.VITE_APP_API_URL?.trim() ?? "";
return { 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}/`, base: isDev || !contextPath ? "/" : `${contextPath}/`,
plugins: [fumadocsMdx(), tailwindcss(), reactRouter(), devtoolsJson()], plugins: [fumadocsMdx(), tailwindcss(), reactRouter(), devtoolsJson()],
resolve: { resolve: {