diff --git a/src/app/page.tsx b/src/app/page.tsx index a99c9b64..e57ec415 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,8 +1,8 @@ -import Footer from '@common/components/layouts/Footer/Footer.server'; +import Footer from '@common/components/layouts/Footer/Footer.client'; + import LandingFull from '@features/landing/components/LandingFull/LandingFull.client'; const RootPage = () => { - return ( <> diff --git a/src/lib/fetcher-response-handlers.ts b/src/lib/fetcher-response-handlers.ts index 519c87be..a5cd891e 100644 --- a/src/lib/fetcher-response-handlers.ts +++ b/src/lib/fetcher-response-handlers.ts @@ -37,12 +37,14 @@ export const shouldReportToSentry = (status: number) => { */ export const handleResponseError = async ( res: Response, + resBody: object, url: string, requestBodyRaw: unknown, method?: string, ) => { const contentType = res.headers.get('content-type'); - const rawText = await res.text(); + // const rawText = await res.text(); + const rawText = JSON.stringify(resBody); // requestBody 직렬화 (로깅용) let requestBody = ''; diff --git a/src/lib/fetcher.ts b/src/lib/fetcher.ts index a4ecb941..e1aa94fe 100644 --- a/src/lib/fetcher.ts +++ b/src/lib/fetcher.ts @@ -45,9 +45,9 @@ export const createFetcher = ({ */ async function innerFunction(path: string, options?: CustomRequestInit): Promise { // Zustand Auth Store를 활용합니다. - const { user, actions } = useAuthStore.getState(); - const { setAccessToken } = actions; - const { accessToken, refreshToken } = user ?? {}; + const { user } = useAuthStore.getState(); + console.log('FETCHER: ', user); + const { accessToken } = user ?? {}; if (!baseURL) { throw new Error( @@ -129,14 +129,17 @@ export const createFetcher = ({ const res = await fetch(url, mergedOptions); // 응답 인터셉터 - 우선 서버로부터 응답이 오긴 한 경우. + const resBody = await res.json(); // 응답 성공시 if (res.ok) { - return handleResponse(res); + // return handleResponse(res); + return resBody; } + // 응답 에러시 // access token 만료 시 자동으로 재발급하도록 함 - const resBody = await res.json(); + // const resBody = await res.json(); // TODO: RT 만료 시에는 로그인 페이지로 이동 시켜야 함 ! if (res.status === 401 && requiresAuth && resBody.code === 'AUTHORIZATION9002') { console.log('AT 만료로 RT 재발급 요청을 합니다.'); @@ -161,16 +164,22 @@ export const createFetcher = ({ // 다시 한 번 실행 try { - const newRes = await fetch(url, { ...options, headers: mergedHeaders }); + const newResMergedOptions = { ...mergedOptions, headers: mergedHeaders }; + const newRes = await fetch(url, newResMergedOptions); + const newResBody = await newRes.json(); + if (newRes.ok) { - return handleResponse(newRes); + // return handleResponse(newRes); + return newResBody; + } else { + return handleResponseError(newRes, newResBody, url, newResMergedOptions.body); } } catch (error) { return handleFetchError(error); } } - return handleResponseError(res, url, mergedOptions.body); + return handleResponseError(res, resBody, url, mergedOptions.body); } catch (error) { // 네트워크 오류나 기타 예외 처리 return handleFetchError(error); diff --git a/tsconfig.json b/tsconfig.json index 49ae3a24..e335af78 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -41,6 +41,13 @@ "@/*": ["*"] } }, - "include": ["image-modules.d.ts", "next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/features/ai-meeting-manager/components/MinutesClient/MinutesClient.client.tsx"], - "exclude": ["node_modules", ".next"] + "include": [ + "image-modules.d.ts", + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + "src/features/ai-meeting-manager/components/MinutesClient/MinutesClient.client.tsx" + ], + "exclude": ["node_modules", ".next", "test/*"] }