fix: restore ISR on public pages — isolate DYNAMIC_SERVER_USAGE root cause
Deploy to VPS / deploy (push) Has been cancelled

Root cause: next-intl's getMessages/getTranslations internally resolves
requestLocale by reading cookies/headers, which trips DYNAMIC_SERVER_USAGE
under ISR. Fixed by calling setRequestLocale(locale) in layout + every
public page — caches the locale in React cache so next-intl never reads
cookies.

Changes:
- [locale]/layout.tsx: +setRequestLocale, +generateStaticParams (5 locales),
  wrap NavigationManager in <Suspense> (uses useSearchParams)
- 5 public pages: force-dynamic → revalidate=60, +setRequestLocale
- HQ dashboard pages: unchanged (still force-dynamic for auth)

Build verified: home/heritage/news pre-render as SSG with 1m revalidation,
slug pages render on-demand with ISR cache. Nginx s-maxage=60 remains as
safety net. Zero DYNAMIC_SERVER_USAGE errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 14:06:20 -05:00
parent 59a146ef10
commit ce8a13d7f8
6 changed files with 47 additions and 29 deletions
@@ -1,5 +1,5 @@
// Force-dynamic — see /[locale]/page.tsx for the rationale.
export const dynamic = "force-dynamic";
// ISR: revalidate every 60s — see /[locale]/page.tsx for the full rationale.
export const revalidate = 60;
import type { Metadata } from "next";
import Link from "next/link";
@@ -9,6 +9,7 @@ import { prisma } from "@/lib/prisma";
import { notFound } from "next/navigation";
import ApplicationClient from "./ApplicationClient";
import { setRequestLocale } from "next-intl/server";
import { getLocalizedData } from "@/lib/i18nHelper";
import {
buildPageMetadata,
@@ -82,16 +83,15 @@ export async function generateMetadata({
}
}
// generateStaticParams intentionally omitted — combined with
// `dynamic = "force-dynamic"`, this guarantees pure SSR per request.
// Having it (even returning [] in prod) made Next.js classify the
// route as SSG-eligible, which conflicted with dynamic API reads
// elsewhere in the tree and surfaced as DYNAMIC_SERVER_USAGE errors.
// generateStaticParams omitted — slug pages render on-demand and are cached
// by ISR (revalidate=60). The DYNAMIC_SERVER_USAGE issue that previously
// blocked this is now fixed via setRequestLocale.
// 🔥 AHORA RECIBIMOS EL LOCALE DESDE LA URL
export default async function ApplicationPage({ params }: { params: Promise<{ slug: string, locale: string }> }) {
const resolvedParams = await params;
const { slug, locale } = resolvedParams;
setRequestLocale(locale);
// 1. Buscamos la Teoría General de la Aplicación
let rawData: any = null;