diff --git a/apps/website/src/lib/cms.ts b/apps/website/src/lib/cms.ts index c13118b..d238918 100644 --- a/apps/website/src/lib/cms.ts +++ b/apps/website/src/lib/cms.ts @@ -1,7 +1,8 @@ import type { Article, Category, Order, Page, Product } from '@homaroma/types' import { API_BASE } from './api' -const defaultRevalidate = 60 +const isDev = process.env.NODE_ENV === 'development' +const defaultRevalidate = isDev ? 0 : 60 type ProductListResponse = { data?: Product[] @@ -62,11 +63,11 @@ export async function fetchJsonResult(path: string, init?: RequestInit & { ne } export async function getCategories(lang = 'all'): Promise { - return await fetchJson(`/categories?lang=${lang}`, { next: { revalidate: 3600 } }) ?? [] + return await fetchJson(`/categories?lang=${lang}`, { next: { revalidate: isDev ? 0 : 3600 } }) ?? [] } export async function getCategoriesResult(lang = 'all'): Promise> { - return await fetchJsonResult(`/categories?lang=${lang}`, { next: { revalidate: 3600 } }) + return await fetchJsonResult(`/categories?lang=${lang}`, { next: { revalidate: isDev ? 0 : 3600 } }) } export async function getCmsPage(slug: string, lang = 'all'): Promise {