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.
This commit is contained in:
lezi-fun committed 2026-08-11 11:43:10 +08:00
1 parent 72e93ca5bb
commit 5c554f27ea
2 files changed
+6 -4

No files matched your search

+4 -2
View File
@@ -6,10 +6,12 @@ import HomeClient from './HomeClient';
// cookies() 是动态 API:禁止静态优化,每次请求 SSR
export const dynamic = 'force-dynamic';
export default function Home() {
export default async function Home() {
let cachedName = '';
try {
cachedName = decodeURIComponent(cookies().get('forumlify-name')?.value || '');
// Next 15+:cookies() 返回 Promise,必须 await
const cookieStore = await cookies();
cachedName = decodeURIComponent(cookieStore.get('forumlify-name')?.value || '');
} catch (e) {
cachedName = '';
}