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, });