This commit is contained in:
hailin 2025-05-21 11:09:02 +08:00
parent 48d56976b3
commit 582ca179d6
2 changed files with 19 additions and 2 deletions

View File

@ -125,10 +125,10 @@ export default async function RootLayout({
return ( return (
<html lang="en" suppressHydrationWarning> <html lang="en" suppressHydrationWarning>
<head> {/* <head>
{/* ✅ 注入客户端运行时环境变量 */} {/* ✅ 注入客户端运行时环境变量 */}
<Script src="/env.js" strategy="beforeInteractive" /> <Script src="/env.js" strategy="beforeInteractive" />
</head> </head> */}
<body className={inter.className}> <body className={inter.className}>
<Providers attribute="class" defaultTheme="dark"> <Providers attribute="class" defaultTheme="dark">

View File

@ -0,0 +1,17 @@
// pages/_document.tsx
import { Html, Head, Main, NextScript } from "next/document"
export default function Document() {
return (
<Html lang="en">
<Head>
{/* ✅ 阻塞加载 env.js在 React 初始化前注入 window.RUNTIME_ENV */}
<script src="/env.js" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}