Cookie が壊れていても落ちないように、読むところを try で囲みました。ビルドは通りましたが、ログに Error: Dynamic server usage と出ています。これは何ですか。
app/page.tsx
Buildで実行
import { cookies } from 'next/headers' Serverで実行
export default async function Page() {Serverで実行
let theme = 'light'Serverで実行
try {Serverで実行
theme = (await cookies()).get('theme')?.value ?? 'light'Serverで実行
} catch (e) {Serverで実行
console.error('caught:', e)Serverで実行
}Serverで実行
return <p>theme={theme}</p>Serverで実行
}出典nextjs.org/docs/messages/dynamic-server-errornextjs.org/docs/app/api-reference/functions/unstable_rethrow