From 4b22120f457385d64b328c97ec2aee9f7297e019 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 6 Feb 2026 11:11:16 +0900 Subject: [PATCH] =?UTF-8?q?260206=5F01=5FENH=20:=20api=20=ED=86=B5?= =?UTF-8?q?=EC=8B=A0=20=EB=AA=A8=EB=93=88=EC=97=90=20=EC=BA=90=EC=8B=B1=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.ts | 1 + src/app/layout.tsx | 6 +++--- src/lib/http-client.ts | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/next.config.ts b/next.config.ts index 5565ca0..d9b9028 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: "standalone", reactCompiler: true, async rewrites() { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 6cff706..156cf5b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -25,9 +25,9 @@ const RootLayout = ({ children }: { children: React.ReactNode}) => { - {children} - - + {children} + + ); } diff --git a/src/lib/http-client.ts b/src/lib/http-client.ts index 81cabda..c702916 100644 --- a/src/lib/http-client.ts +++ b/src/lib/http-client.ts @@ -33,6 +33,11 @@ export type QueryValue = string | string[] | undefined; export type Query = Record; export type PathParams = Record; +export type NextFetchOptions = { + revalidate?: number; + tags?: string[]; +}; + export type RequestOptions = { method?: HttpMethod; pathParams?: PathParams; @@ -47,6 +52,8 @@ export type RequestOptions = { autoLogoutOnAuthError?: boolean; expectText?: boolean; expectBinary?: boolean; + cache?: RequestCache; // "force-cache" | "no-store" | ... + next?: NextFetchOptions; // Next 서버 fetch 확장 옵션 }; export type HttpClientOptions = { @@ -140,12 +147,18 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {}) const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? defaultTimeoutMs); + const isServer = typeof window === "undefined"; + const cacheMode: RequestCache = options.cache ?? (isServer && options.next ? "force-cache" : "no-store"); + const nextOpt = isServer ? options.next : undefined; + try { const res = await fetch(url.toString(), { method: options.method ?? (body ? "POST" : "GET"), headers, body, - cache: "no-store", + cache: cacheMode, + // TS에서 RequestInit에 next가 없어서 캐스팅 필요 + ...(nextOpt ? ({ next: nextOpt } as any) : {}), signal: controller.signal, });