-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy: 지금까지 작업 배포
- Loading branch information
Showing
19 changed files
with
133 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
## 이슈번호 | ||
|
||
<!-- - close 뒤에 이슈 달아주기 --> | ||
close: # | ||
close # | ||
|
||
## 작업 내용 설명 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,23 @@ | ||
import axios from "axios"; | ||
|
||
// import useAuthStore from '@/store/AuthStore' | ||
type AuthStoreState = { | ||
authTokens: { | ||
accessToken: string; | ||
refreshToken: string; | ||
}; | ||
userId: number; | ||
}; | ||
|
||
const { state }: { state: AuthStoreState } = JSON.parse(localStorage.getItem("auth-store") || "{}"); | ||
|
||
export const axiosAPI = axios.create({ | ||
baseURL: | ||
process.env.NODE_ENV === "development" | ||
? "http://localhost:5173" | ||
: import.meta.env.VITE_BASE_URL, | ||
}); | ||
|
||
// Add a request interceptor | ||
axiosAPI.interceptors.request.use( | ||
function (config) { | ||
// 요청 바로 직전 | ||
// axios 설정값에 대해 작성합니다. | ||
|
||
config.headers["Authorization"] = `${localStorage.getItem("jwt")}`; | ||
|
||
return config; | ||
}, | ||
function (error) { | ||
// 요청 에러 처리를 작성합니다. | ||
return Promise.reject(error); | ||
}, | ||
); | ||
|
||
// Add a response interceptor | ||
axiosAPI.interceptors.response.use( | ||
function (response) { | ||
/* | ||
http status가 200인 경우 | ||
응답 바로 직전에 대해 작성합니다. | ||
.then() 으로 이어집니다. | ||
*/ | ||
return response; | ||
}, | ||
|
||
function (error) { | ||
/* | ||
http status가 200이 아닌 경우 | ||
응답 에러 처리를 작성합니다. | ||
.catch() 으로 이어집니다. | ||
*/ | ||
if (error.response && error.response.status === 401) { | ||
return new Promise(() => {}); //이행되지 않은 Promise를 반환하여 Promise Chaining 끊어주기 | ||
} | ||
return Promise.reject(error); | ||
headers: { | ||
Authorization: `${state.authTokens.accessToken}`, | ||
}, | ||
); | ||
|
||
// Response interceptor | ||
// function interceptorResponseFulfilled(res: AxiosResponse) { | ||
// if (200 <= res.status && res.status < 300) { | ||
// return res | ||
// } | ||
|
||
// return Promise.reject(res) | ||
// } | ||
|
||
// function interceptorResponseRejected(error: AxiosError<ApiErrorScheme>) { | ||
// if (error.response?.data?.message) { | ||
// return Promise.reject(new ApiException(error.response.data, error.response.status)) | ||
// } | ||
// } | ||
}); | ||
|
||
// axiosAPI.interceptors.response.use(interceptorResponseFulfilled, interceptorResponseRejected) | ||
// TODO: axiosAPI.interceptors.response.use()를 사용하여 refreshToken이 만료되었을 때, accessToken을 재발급 받는 로직을 구현해야 합니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import getMyProfileData from "@/apis/profile/getMyProfileData.ts"; | ||
|
||
export const getMyProfileDataOptions = { | ||
queryKey: ["myProfileData"], | ||
queryFn: getMyProfileData, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.