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..f19c844 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,37 +40,20 @@ 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; - } }; \ No newline at end of file diff --git a/src/pages/my-page/index.tsx b/src/pages/my-page/index.tsx index 0d2ec57..0cc82a7 100644 --- a/src/pages/my-page/index.tsx +++ b/src/pages/my-page/index.tsx @@ -129,8 +129,8 @@ const MyPage = () => { clearAuthData(); closeModal(); navigate('/login', { replace: true }); - } catch (error) { - console.error('회원탈퇴 실패:', error); + } catch { + 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..75e671e 100644 --- a/src/pages/signup/profile-create-page.tsx +++ b/src/pages/signup/profile-create-page.tsx @@ -295,11 +295,7 @@ const ProfileCreatePage = () => { await uploadProfileImage( profileImageFile, ); - } catch (error) { - console.error( - '프로필 이미지 업로드 실패:', - error, - ); + } catch { alert( '프로필은 생성되었지만 이미지 업로드에 실패했습니다. 마이페이지에서 다시 등록해주세요.', @@ -315,11 +311,7 @@ const ProfileCreatePage = () => { navigate('/signup/complete', { replace: true, }); - } catch (error) { - console.error( - '프로필 생성 실패:', - error, - ); + } catch { alert( '프로필 생성에 실패했습니다. 다시 시도해주세요.', diff --git a/src/pages/signup/terms-page.tsx b/src/pages/signup/terms-page.tsx index 8b567d8..3ecaa8c 100644 --- a/src/pages/signup/terms-page.tsx +++ b/src/pages/signup/terms-page.tsx @@ -95,8 +95,7 @@ if ( }, {}); setAgreements(initialAgreements); - } catch (error) { - console.error('약관 조회 실패:', error); + } catch { setLoadErrorMessage('약관을 불러오지 못했습니다.'); } finally { @@ -201,8 +200,7 @@ if ( navigate('/signup/profile', { replace: true, }); - } catch (error) { - console.error('소셜 회원가입 실패:', error); + } catch { setSubmitErrorMessage('회원가입 중 오류가 발생했습니다.'); } finally {