From 74eb86b2638a6faa6ade9151c1aee2906b3ec9bb Mon Sep 17 00:00:00 2001 From: hyejj19 Date: Thu, 29 Oct 2026 14:37:03 +0900 Subject: [PATCH] fix: render the home page on request so banners and editor's picks are not empty after deploy The home route was prerendered at build time. The CI build cannot reach the internal product API (ENOTFOUND product-api), so banners and editor's picks were baked in empty and served until the 5-minute revalidation regenerated the page. Render on request instead; the API responses keep their fetch revalidate cache. Co-Authored-By: Claude Opus 5.5 --- src/app/(primary)/page.tsx | 4 ++++ src/app/(primary)/page.vitest.test.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/app/(primary)/page.vitest.test.ts diff --git a/src/app/(primary)/page.tsx b/src/app/(primary)/page.tsx index e1ec81fe..3dc10d3d 100644 --- a/src/app/(primary)/page.tsx +++ b/src/app/(primary)/page.tsx @@ -18,6 +18,10 @@ import { import { filterBannersByDate } from './_utils/filterBannersByDate'; import { fetchHomeEditorPicks } from './_utils/fetchHomeEditorPicks'; +// 빌드 환경(CI)에서는 내부 API에 접근할 수 없어 미리 만들면 배너·에디터 추천이 빈 채로 배포된다. +// 요청 시 렌더링하고, API 응답은 각 fetch의 revalidate 캐시를 그대로 쓴다. +export const dynamic = 'force-dynamic'; + async function getBanners(): Promise { try { const baseUrl = `${getInternalServerOrigin()}/api/v1`; diff --git a/src/app/(primary)/page.vitest.test.ts b/src/app/(primary)/page.vitest.test.ts new file mode 100644 index 00000000..18cd4551 --- /dev/null +++ b/src/app/(primary)/page.vitest.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it, vi } from 'vitest'; + +vi.mock('@/components/feature/home/HomeCarousel', () => ({ + default: () => null, +})); + +describe('홈 페이지 렌더링 시점', () => { + it('빌드 때 미리 만들지 않고 요청 시 렌더링한다 (CI 빌드에서는 내부 API에 접근할 수 없음)', async () => { + const page = await import('./page'); + + expect(page.dynamic).toBe('force-dynamic'); + }); +});