From b7701a4b56c3a2e39c80deedc41c89988124f313 Mon Sep 17 00:00:00 2001 From: woohyun Date: Sat, 15 Aug 2026 17:27:35 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Refactor]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=98=EC=86=94=20=EB=A1=9C=EA=B7=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/api.ts | 94 ------------------------ src/apis/token.ts | 15 +--- src/pages/my-page/index.tsx | 2 +- src/pages/my-page/profile-edit-page.tsx | 4 +- src/pages/signup/profile-create-page.tsx | 8 -- src/pages/signup/terms-page.tsx | 2 - 6 files changed, 3 insertions(+), 122 deletions(-) diff --git a/src/apis/api.ts b/src/apis/api.ts index 46d597e..864abb5 100644 --- a/src/apis/api.ts +++ b/src/apis/api.ts @@ -23,18 +23,6 @@ api.interceptors.request.use( (config) => { const accessToken = getAccessToken(); - console.log('========== API REQUEST =========='); - console.log('[REQUEST] method:', config.method); - console.log('[REQUEST] url:', config.url); - console.log( - '[REQUEST] baseURL:', - config.baseURL, - ); - console.log( - '[REQUEST] withCredentials:', - config.withCredentials, - ); - if (accessToken) { config.headers.Authorization = /^Bearer\s+/i.test(accessToken) @@ -46,51 +34,21 @@ api.interceptors.request.use( return config; }, (error: AxiosError) => { - console.error( - '[REQUEST INTERCEPTOR ERROR]', - error, - ); - return Promise.reject(error); }, ); api.interceptors.response.use( (response) => { - console.log('========== API RESPONSE =========='); - console.log('[RESPONSE] url:', response.config.url); - console.log('[RESPONSE] status:', response.status); - return response; }, async (error: AxiosError) => { - console.error('========== API ERROR =========='); - console.error( - '[ERROR] status:', - error.response?.status, - ); - console.error( - '[ERROR] url:', - error.config?.url, - ); - console.error( - '[ERROR] method:', - error.config?.method, - ); - console.error( - '[ERROR] message:', - error.message, - ); const originalRequest = error.config as | RetryRequestConfig | undefined; if (!originalRequest) { - console.error( - '[INTERCEPTOR] 기존 요청 정보가 없습니다.', - ); - return Promise.reject(error); } @@ -115,52 +73,21 @@ api.interceptors.response.use( originalRequest.url?.includes(url), ); - console.log( - '========== INTERCEPTOR CHECK ==========', - ); - console.log( - '[INTERCEPTOR] 401 여부:', - isUnauthorized, - ); - console.log( - '[INTERCEPTOR] 제외 API 여부:', - isExcludedRequest, - ); - console.log( - '[INTERCEPTOR] 이미 재시도했는지:', - Boolean(originalRequest._retry), - ); - if ( !isUnauthorized || originalRequest._retry || isExcludedRequest ) { - console.log( - '[INTERCEPTOR] 재발급을 시도하지 않습니다.', - ); return Promise.reject(error); } originalRequest._retry = true; - console.log( - '[INTERCEPTOR] Access Token 재발급 시작', - ); - try { const newAccessToken = await reissueAccessToken(); - console.log( - '[INTERCEPTOR] Access Token 재발급 성공', - ); - console.log( - '[INTERCEPTOR] 기존 요청 재시도:', - originalRequest.url, - ); - originalRequest.headers = originalRequest.headers ?? {}; @@ -169,30 +96,9 @@ api.interceptors.response.use( return api(originalRequest); } catch (reissueError) { - const axiosError = - reissueError as AxiosError; - - console.error( - '========== REISSUE FINAL ERROR ==========', - ); - console.error( - '[INTERCEPTOR] 재발급 실패 status:', - axiosError.response?.status, - ); - console.error( - '[INTERCEPTOR] 재발급 실패 message:', - axiosError.message, - ); clearAuthData(); - console.log( - '[INTERCEPTOR] 인증 데이터 삭제 완료', - ); - - // 디버깅 중에는 페이지 이동을 막아두는 게 좋음 - // window.location.replace('/login'); - return Promise.reject(reissueError); } }, diff --git a/src/apis/token.ts b/src/apis/token.ts index 1c0cac6..391344b 100644 --- a/src/apis/token.ts +++ b/src/apis/token.ts @@ -1,4 +1,4 @@ -import axios, { AxiosError } from 'axios'; +import axios from 'axios'; interface ApiResponse { isSuccess: boolean; @@ -40,36 +40,23 @@ export const clearAuthData = (): void => { }; export const reissueAccessToken = async (): Promise => { - console.log('========== ACCESS TOKEN REISSUE =========='); - console.log('[REISSUE] API URL :', import.meta.env.VITE_API_URL); - console.log('[REISSUE] 요청 시작'); try { const response = await refreshApi.post>( '/api/auth/reissue', ); - console.log('[REISSUE] 응답 상태 :', response.status); - const newAccessToken = response.data.result.accessToken; if (!newAccessToken) { - console.error('[REISSUE] Access Token 없음'); throw new Error('재발급 응답에 Access Token이 없습니다.'); } setAccessToken(newAccessToken); - console.log('[REISSUE] LocalStorage 저장 완료'); - return newAccessToken; } catch (error) { - const axiosError = error as AxiosError; - - console.error('========== REISSUE ERROR =========='); - console.error('Status :', axiosError.response?.status); - console.error('Message :', axiosError.message); throw error; } diff --git a/src/pages/my-page/index.tsx b/src/pages/my-page/index.tsx index 0d2ec57..b9e9dee 100644 --- a/src/pages/my-page/index.tsx +++ b/src/pages/my-page/index.tsx @@ -130,7 +130,7 @@ const MyPage = () => { closeModal(); navigate('/login', { replace: true }); } catch (error) { - console.error('회원탈퇴 실패:', error); + alert('회원탈퇴에 실패했습니다. 다시 시도해주세요.',); } }; diff --git a/src/pages/my-page/profile-edit-page.tsx b/src/pages/my-page/profile-edit-page.tsx index 7e5b0b2..197e733 100644 --- a/src/pages/my-page/profile-edit-page.tsx +++ b/src/pages/my-page/profile-edit-page.tsx @@ -224,9 +224,7 @@ const ProfileEditForm = ({ }); }, - onError: (error) => { - console.error('프로필 수정 실패:', error); - + onError: () => { alert( '프로필 수정에 실패했습니다. 다시 시도해주세요.', ); diff --git a/src/pages/signup/profile-create-page.tsx b/src/pages/signup/profile-create-page.tsx index f1116ac..3beb15d 100644 --- a/src/pages/signup/profile-create-page.tsx +++ b/src/pages/signup/profile-create-page.tsx @@ -296,10 +296,6 @@ const ProfileCreatePage = () => { profileImageFile, ); } catch (error) { - console.error( - '프로필 이미지 업로드 실패:', - error, - ); alert( '프로필은 생성되었지만 이미지 업로드에 실패했습니다. 마이페이지에서 다시 등록해주세요.', @@ -316,10 +312,6 @@ const ProfileCreatePage = () => { replace: true, }); } catch (error) { - console.error( - '프로필 생성 실패:', - error, - ); alert( '프로필 생성에 실패했습니다. 다시 시도해주세요.', diff --git a/src/pages/signup/terms-page.tsx b/src/pages/signup/terms-page.tsx index 8b567d8..8de74a4 100644 --- a/src/pages/signup/terms-page.tsx +++ b/src/pages/signup/terms-page.tsx @@ -96,7 +96,6 @@ if ( setAgreements(initialAgreements); } catch (error) { - console.error('약관 조회 실패:', error); setLoadErrorMessage('약관을 불러오지 못했습니다.'); } finally { @@ -202,7 +201,6 @@ if ( replace: true, }); } catch (error) { - console.error('소셜 회원가입 실패:', error); setSubmitErrorMessage('회원가입 중 오류가 발생했습니다.'); } finally { From e37151b7c797527689105e11ed917eeefc17b0eb Mon Sep 17 00:00:00 2001 From: woohyun Date: Sat, 15 Aug 2026 17:35:37 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Refactor]=20ESLint=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/token.ts | 6 +----- src/pages/my-page/index.tsx | 2 +- src/pages/signup/profile-create-page.tsx | 4 ++-- src/pages/signup/terms-page.tsx | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/apis/token.ts b/src/apis/token.ts index 391344b..f19c844 100644 --- a/src/apis/token.ts +++ b/src/apis/token.ts @@ -41,7 +41,7 @@ export const clearAuthData = (): void => { export const reissueAccessToken = async (): Promise => { - try { + const response = await refreshApi.post>( '/api/auth/reissue', ); @@ -56,8 +56,4 @@ export const reissueAccessToken = async (): Promise => { setAccessToken(newAccessToken); return newAccessToken; - } catch (error) { - - throw error; - } }; \ No newline at end of file diff --git a/src/pages/my-page/index.tsx b/src/pages/my-page/index.tsx index b9e9dee..0cc82a7 100644 --- a/src/pages/my-page/index.tsx +++ b/src/pages/my-page/index.tsx @@ -129,7 +129,7 @@ const MyPage = () => { clearAuthData(); closeModal(); navigate('/login', { replace: true }); - } catch (error) { + } catch { alert('회원탈퇴에 실패했습니다. 다시 시도해주세요.',); } }; diff --git a/src/pages/signup/profile-create-page.tsx b/src/pages/signup/profile-create-page.tsx index 3beb15d..75e671e 100644 --- a/src/pages/signup/profile-create-page.tsx +++ b/src/pages/signup/profile-create-page.tsx @@ -295,7 +295,7 @@ const ProfileCreatePage = () => { await uploadProfileImage( profileImageFile, ); - } catch (error) { + } catch { alert( '프로필은 생성되었지만 이미지 업로드에 실패했습니다. 마이페이지에서 다시 등록해주세요.', @@ -311,7 +311,7 @@ const ProfileCreatePage = () => { navigate('/signup/complete', { replace: true, }); - } catch (error) { + } catch { alert( '프로필 생성에 실패했습니다. 다시 시도해주세요.', diff --git a/src/pages/signup/terms-page.tsx b/src/pages/signup/terms-page.tsx index 8de74a4..3ecaa8c 100644 --- a/src/pages/signup/terms-page.tsx +++ b/src/pages/signup/terms-page.tsx @@ -95,7 +95,7 @@ if ( }, {}); setAgreements(initialAgreements); - } catch (error) { + } catch { setLoadErrorMessage('약관을 불러오지 못했습니다.'); } finally { @@ -200,7 +200,7 @@ if ( navigate('/signup/profile', { replace: true, }); - } catch (error) { + } catch { setSubmitErrorMessage('회원가입 중 오류가 발생했습니다.'); } finally {