Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<LandingFull />
Expand Down
4 changes: 3 additions & 1 deletion src/lib/fetcher-response-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
25 changes: 17 additions & 8 deletions src/lib/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const createFetcher = ({
*/
async function innerFunction<T>(path: string, options?: CustomRequestInit): Promise<T> {
// 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(
Expand Down Expand Up @@ -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 재발급 요청을 합니다.');
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"]
}