dm: 콘텐츠 관련 refresh

This commit is contained in:
2026-05-22 14:56:58 +09:00
parent 9b4d2d410d
commit 7cbde80466
2 changed files with 38 additions and 7 deletions
+16 -2
View File
@@ -4,14 +4,24 @@ import { unstable_cache } from "next/cache";
import { ENDPOINT } from "@/src/shared/config";
function getServerBaseUrl() {
const port = process.env.PORT ?? process.env.NEXT_PUBLIC_PORT ?? "3000";
const proxyHost = process.env.NEXT_PUBLIC_PROXY_HOST;
if (process.env.NODE_ENV === "production" && process.env.HOSTNAME) {
return `http://${process.env.HOSTNAME}:${port}`;
}
return proxyHost || `http://localhost:${port}`;
}
export const getCachedContentDetail = unstable_cache(
async (contsSn: number, menuCd: string) => {
const baseUrl = process.env.NEXT_PUBLIC_PROXY_HOST || "http://localhost:3015";
const baseUrl = getServerBaseUrl();
const res = await fetch(
`${baseUrl}${ENDPOINT.CMS_SERVICE.CONTENTS}/${contsSn}?menuCd=${menuCd}`,
{
next: { revalidate: 3600, tags: [`content:${contsSn}`] },
next: { revalidate: 0, tags: [`content:${contsSn}`] },
}
);
@@ -23,4 +33,8 @@ export const getCachedContentDetail = unstable_cache(
return res.json();
},
["dm-content-detail"],
{
revalidate: 86400, // 1시간마다 자동 갱신 (선택 사항)
tags: ["dm-content-detail"], // 여기에 태그를 명시해야 revalidateTag가 작동합니다.
}
);