fix: pass locale explicitly to next-intl helpers (DYNAMIC_SERVER_USAGE)
Deploy to VPS / deploy (push) Has been cancelled
Deploy to VPS / deploy (push) Has been cancelled
Production logs were spamming "DYNAMIC_SERVER_USAGE" errors and every
ISR-cached page (home, news, heritage, applications, news/[slug]) was
500-ing. Root cause: when force-dynamic was replaced with revalidate=60
last commit batch, the implicit locale-resolution path through
next-intl's getTranslations() / getLocale() / getMessages() became a
problem. Without an explicit locale arg, next-intl reads cookies()
under the hood — which trips Next.js's "dynamic API used inside a
static / ISR render" guard and aborts with DYNAMIC_SERVER_USAGE.
Fix: pass the locale (already known from the URL via params) every
time we call next-intl on the server.
CHANGES
- src/components/layout/Footer.tsx
- Now accepts `locale` as a prop instead of awaiting getLocale()
- getTranslations({ locale, namespace: "Footer" })
- src/app/[locale]/layout.tsx
- Passes locale prop to <Footer locale={locale} />
- getMessages({ locale }) instead of getMessages()
- src/components/sections/PatrizioLegacy.tsx
- Accepts `locale` prop, passes it to getTranslations
- src/app/[locale]/page.tsx
- Renders <PatrizioLegacy locale={locale} />
- src/app/[locale]/news/page.tsx (body)
- getTranslations({ locale, namespace: "NewsHub" })
- src/app/[locale]/heritage/page.tsx (body)
- getTranslations({ locale, namespace: "HeritagePage" })
The generateMetadata / generateStaticParams paths in news/[slug] and
heritage already passed locale correctly — only the page bodies and
shared components were leaking dynamic reads.
Net effect: all five ISR pages render statically again, the error spam
in `docker compose logs app` clears, and /en/applications/digital-print
loads its server component without falling through to the error boundary.
This commit is contained in:
@@ -197,8 +197,8 @@ export default async function HeritagePage({ params }: { params: Promise<{ local
|
||||
const resolvedParams = await params;
|
||||
const locale = resolvedParams.locale;
|
||||
|
||||
// 🔥 Cargamos el diccionario para los textos fijos
|
||||
const t = await getTranslations("HeritagePage");
|
||||
// Pass locale explicitly so getTranslations stays static-friendly under ISR.
|
||||
const t = await getTranslations({ locale, namespace: "HeritagePage" });
|
||||
|
||||
let rawSections: any[] = [];
|
||||
try {
|
||||
|
||||
@@ -72,7 +72,7 @@ export default async function RootLayout({
|
||||
}
|
||||
|
||||
const [messages, branding, social] = await Promise.all([
|
||||
getMessages(),
|
||||
getMessages({ locale }),
|
||||
getBranding(),
|
||||
getSocialLinks(),
|
||||
]);
|
||||
@@ -114,7 +114,7 @@ export default async function RootLayout({
|
||||
{children}
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
<Footer locale={locale} />
|
||||
<SilentObserver />
|
||||
|
||||
</NextIntlClientProvider>
|
||||
|
||||
@@ -31,8 +31,8 @@ export default async function NewsHub({ params }: { params: Promise<{ locale: st
|
||||
const resolvedParams = await params;
|
||||
const locale = resolvedParams.locale;
|
||||
|
||||
// 🔥 LLAMAMOS AL DICCIONARIO
|
||||
const t = await getTranslations("NewsHub");
|
||||
// Pass locale explicitly so getTranslations stays static-friendly under ISR.
|
||||
const t = await getTranslations({ locale, namespace: "NewsHub" });
|
||||
|
||||
let rawArticles: any[] = [];
|
||||
try {
|
||||
|
||||
@@ -176,7 +176,7 @@ export default async function Home({ params }: { params: Promise<{ locale: strin
|
||||
<ApplicationsDashboard dbApps={dbApps} />
|
||||
<GlobalOperations dbNodes={mapNodes} dbApps={dbApps} />
|
||||
<OurStory dbTimeline={dbTimeline} />
|
||||
<PatrizioLegacy />
|
||||
<PatrizioLegacy locale={locale} />
|
||||
<div className="h-64 w-full"></div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user