Files
forumlify/app/page.js
T
lezi-fun ef9d8b8f9c fix: Next 16 cookies() is async — await it in Home (page rendering error
cookies().get() without await threw in Next 16 (sync dynamic API
removed), breaking the whole Home SSR render → layout broken, spinner
restart, flash. Await cookies() before reading forumlify-name.
Also raise glass-bg opacity (0.18→0.62 light / 0.35→0.60 dark) so
cards/navbar/modal aren't see-through.
2026-08-11 11:43:27 +08:00

20 lines
674 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 主页:Server Component —— 从 cookie 读取缓存论坛名(SSR 首帧即输出),
// 其余逻辑在客户端 HomeClient 中
import { cookies } from 'next/headers';
import HomeClient from './HomeClient';
// cookies() 是动态 API:禁止静态优化,每次请求 SSR
export const dynamic = 'force-dynamic';
export default async function Home() {
let cachedName = '';
try {
// Next 15+:cookies() 返回 Promise,必须 await
const cookieStore = await cookies();
cachedName = decodeURIComponent(cookieStore.get('forumlify-name')?.value || '');
} catch (e) {
cachedName = '';
}
return <HomeClient cachedName={cachedName} />;
}