Skip to content

Commit 1db0c44

Browse files
Merge branch 'develop' of https://github.com/SOPT-36-NINEDOT/NINEDOT-CLIENT into refactor/#192/myTodoBottom
2 parents 08d3405 + f2d95f3 commit 1db0c44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1347
-1544
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"react": "^19.1.0",
3131
"react-dom": "^19.1.0",
3232
"react-redux": "^9.2.0",
33-
"react-router-dom": "^7.6.3"
33+
"react-router-dom": "^7.6.3",
34+
"zustand": "^5.0.8"
3435
},
3536
"devDependencies": {
3637
"@chromatic-com/storybook": "^4.0.1",

pnpm-lock.yaml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/auth/refreshToken/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import axiosInstance from '@/api/axiosInstance';
2+
import { END_POINT } from '@/api/constant/endPoint';
3+
import type { BaseResponse } from '@/type/api';
4+
5+
export type RefreshResponse = {
6+
accessToken: string;
7+
message: string;
8+
};
9+
10+
export const postRefreshToken = async () => {
11+
const { data } = await axiosInstance.post<BaseResponse<RefreshResponse>>(
12+
`/${END_POINT.AUTH}/refresh`,
13+
);
14+
return data.data;
15+
};

src/api/axiosInstance.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios';
22

33
import { HTTP_STATUS } from '@/api/constant/httpStatus';
4+
import { postRefreshToken } from '@/api/auth/refreshToken';
45

56
const axiosInstance = axios.create({
67
baseURL: import.meta.env.VITE_API_BASE_URL,
@@ -24,12 +25,23 @@ axiosInstance.interceptors.request.use(
2425
// 응답 인터셉터
2526
axiosInstance.interceptors.response.use(
2627
(response) => response,
27-
(error) => {
28+
async (error) => {
29+
const originalRequest = error.config;
30+
2831
if (error.response) {
2932
const { status } = error.response;
3033

3134
if (status === HTTP_STATUS.UNAUTHORIZED) {
32-
// 인증 실패 처리
35+
try {
36+
const { accessToken } = await postRefreshToken();
37+
localStorage.setItem('accessToken', accessToken);
38+
39+
axiosInstance.defaults.headers.Authorization = `Bearer ${accessToken}`;
40+
originalRequest.headers.Authorization = `Bearer ${accessToken}`;
41+
} catch (refreshError) {
42+
console.error('리프레시 토큰 만료, 재로그인 필요');
43+
return Promise.reject(refreshError);
44+
}
3345
}
3446

3547
if (status === HTTP_STATUS.INTERNAL_SERVER_ERROR) {

src/api/domain/signup/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { END_POINT } from '@/api/constant/endPoint';
33
import type { JobResponse } from '@/api/domain/signup/type/JobResponse';
44
import type { PersonaResponse } from '@/api/domain/signup/type/PersonaResponse';
55
import type { SignupResponse } from '@/api/domain/signup/type/SignupResponse';
6-
import type { UserInfoResponse } from '@/api/domain/signup/type/UserInfoResponse';
6+
import type { UserType } from '@/store/types/authTypes';
77
import type { BaseResponse } from '@/type/api';
88

99
export const getJobList = async () => {
@@ -21,7 +21,7 @@ export const postSignUp = async (payload: SignupResponse) => {
2121
};
2222

2323
export const getUser = async () => {
24-
const { data } = await axiosInstance.get<BaseResponse<UserInfoResponse>>('/users/info');
24+
const { data } = await axiosInstance.get<BaseResponse<UserType>>('/users/info');
2525
return data.data;
2626
};
2727

src/api/domain/signup/type/UserInfoResponse.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/common/component/MandalartTextField/MandalartTextField.css.ts

Lines changed: 0 additions & 188 deletions
This file was deleted.

0 commit comments

Comments
 (0)