Docker production build runs without DATABASE_URL, so any page Next tries to prerender at build (force-static / revalidate without a dynamic segment) fails on the Prisma call. Homepage, genre page, and sitemap previously had page-level revalidate, forcing prerender. Add force-dynamic to each and move the revalidation inside an unstable_cache wrapper around the Prisma query — result still cached 5m / 1h at runtime, but build no longer touches the DB. Detail page (/manga/[slug]) keeps page-level revalidate since its dynamic segment without generateStaticParams was never prerendered at build anyway. Update CLAUDE.md caching section to reflect the new strategy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33 lines
907 B
TypeScript
33 lines
907 B
TypeScript
import { unstable_cache } from "next/cache";
|
|
import { prisma } from "@/lib/db";
|
|
import { collectGenres } from "@/lib/genres";
|
|
import { TrendingCarousel } from "@/components/TrendingCarousel";
|
|
import { GenreTabs } from "@/components/GenreTabs";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
const getPublishedManga = unstable_cache(
|
|
async () =>
|
|
prisma.manga.findMany({
|
|
where: { status: "PUBLISHED" },
|
|
orderBy: { updatedAt: "desc" },
|
|
include: { _count: { select: { chapters: true } } },
|
|
}),
|
|
["home-manga-list"],
|
|
{ revalidate: 300 }
|
|
);
|
|
|
|
export default async function Home() {
|
|
const manga = await getPublishedManga();
|
|
|
|
const trending = manga.slice(0, 10);
|
|
const genres = collectGenres(manga);
|
|
|
|
return (
|
|
<div className="max-w-6xl mx-auto px-4 py-5 space-y-8">
|
|
<TrendingCarousel manga={trending} />
|
|
<GenreTabs manga={manga} genres={genres} />
|
|
</div>
|
|
);
|
|
}
|