This commit is contained in:
hailin 2025-05-21 13:30:52 +08:00
parent ac537df133
commit 14cd36579b
1 changed files with 12 additions and 2 deletions

View File

@ -1,11 +1,21 @@
/*
eslint-disable @next/next/no-sync-scripts
Please do not remove:
We are enforcing synchronous loading of /env.js here to inject window.RUNTIME_ENV
to ensure dynamic configurations like Supabase are available before React starts.
*/
import { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";
export default function Document() {
return (
<Html lang="en">
<Head>
{/* 使用 defer 确保 env.js 加载顺序 */}
<script src="/env.js" defer />
{/* Use next/script to load env.js synchronously */}
<Script
src="/env.js"
strategy="beforeInteractive" // Ensures the script loads before React starts
/>
</Head>
<body>
<Main />