260206_07_ENH: 필터 아이콘 추가 및 api통신에 캐시 기능 추가, LIFE_STAGE_COLUMNS에 미혼, 독립 시니어 rowspan 적용

This commit is contained in:
2026-02-06 16:30:29 +09:00
parent 17d75e3f3a
commit b7282bd07d
4 changed files with 23 additions and 6 deletions

View File

@@ -33,6 +33,11 @@ export type QueryValue = string | string[] | undefined;
export type Query = Record<string, QueryValue>;
export type PathParams = Record<string, string | number | boolean>;
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,17 @@ 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,
...(nextOpt ? ({ next: nextOpt } as any) : {}),
signal: controller.signal,
});
@@ -292,4 +304,4 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
return { request, get, post, put, patch, del, postForm, putForm };
};
export const nextApi = createHttpClient(clientEnv.API_BASE);
export const nextApi = createHttpClient(clientEnv.API_BASE);