Skip to content

Commit a555311

Browse files
committed
Refactor: axiosInstance에서 불필요한 속성 삭제
1 parent 530e4f2 commit a555311

File tree

2 files changed

+55
-66
lines changed

2 files changed

+55
-66
lines changed

lib/api/axiosInstanceApi.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ import axios from "axios";
22

33
const axiosInstance = axios.create({
44
baseURL: process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000",
5-
timeout: 10000,
6-
withCredentials: true,
75
});
86

97
export const proxy = axios.create({
108
// 배포 이후에는 배포된 URL로 변경해야 함.
119
baseURL: "http://localhost:3000",
12-
timeout: 10000,
13-
withCredentials: true,
1410
});
1511

1612
proxy.interceptors.response.use(

store/useAuthStore.tsx

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -22,75 +22,68 @@ interface AuthStore {
2222
logout: () => Promise<void>;
2323
}
2424

25-
const useAuthStore = create<AuthStore>()(
26-
persist(
27-
(set) => ({
28-
user: null,
29-
isLoggedIn: false,
25+
const useAuthStore = create<AuthStore>()((set) => ({
26+
user: null,
27+
isLoggedIn: false,
3028

31-
checkLogin: async () => {
32-
try {
33-
const response = await proxy.get("/api/auth/sign-check");
34-
if (response.data.isLoggedIn) {
35-
const userInfo = await getUserInfo();
36-
if (userInfo) {
37-
set({ isLoggedIn: true, user: userInfo });
38-
}
39-
} else {
40-
set({ isLoggedIn: false, user: null });
41-
}
42-
} catch (error) {
43-
console.error("로그인 상태 확인 중 오류 발생", error);
44-
set({ isLoggedIn: false, user: null });
29+
checkLogin: async () => {
30+
try {
31+
const response = await proxy.get("/api/auth/sign-check");
32+
if (response.data.isLoggedIn) {
33+
const userInfo = await getUserInfo();
34+
if (userInfo) {
35+
set({ isLoggedIn: true, user: userInfo });
4536
}
46-
},
37+
} else {
38+
set({ isLoggedIn: false, user: null });
39+
}
40+
} catch (error) {
41+
console.error("로그인 상태 확인 중 오류 발생", error);
42+
set({ isLoggedIn: false, user: null });
43+
}
44+
},
4745

48-
login: async (body) => {
49-
try {
50-
const { email, password } = body;
51-
const response = await postSignIn({ email, password });
52-
if (response) {
53-
const userInfo = await getUserInfo();
54-
if (userInfo) {
55-
set({ isLoggedIn: true, user: userInfo });
56-
return true;
57-
}
58-
}
59-
} catch (error) {
60-
console.error("로그인 중 에러가 발생했습니다", error);
46+
login: async (body) => {
47+
try {
48+
const { email, password } = body;
49+
const response = await postSignIn({ email, password });
50+
if (response) {
51+
const userInfo = await getUserInfo();
52+
if (userInfo) {
53+
set({ isLoggedIn: true, user: userInfo });
54+
return true;
6155
}
62-
return false;
63-
},
56+
}
57+
} catch (error) {
58+
console.error("로그인 중 에러가 발생했습니다", error);
59+
}
60+
return false;
61+
},
6462

65-
SNSLogin: async (provider, body) => {
66-
try {
67-
const response = await postEasySignIn(provider, body);
68-
if (response) {
69-
const userInfo = await getUserInfo();
70-
if (userInfo) {
71-
set({ isLoggedIn: true, user: userInfo });
72-
return true;
73-
}
74-
}
75-
} catch (error) {
76-
console.error("소셜 로그인 중 에러가 발생했습니다.", error);
63+
SNSLogin: async (provider, body) => {
64+
try {
65+
const response = await postEasySignIn(provider, body);
66+
if (response) {
67+
const userInfo = await getUserInfo();
68+
if (userInfo) {
69+
set({ isLoggedIn: true, user: userInfo });
70+
return true;
7771
}
78-
return false;
79-
},
72+
}
73+
} catch (error) {
74+
console.error("소셜 로그인 중 에러가 발생했습니다.", error);
75+
}
76+
return false;
77+
},
8078

81-
logout: async () => {
82-
try {
83-
await proxy.post("/api/auth/sign-out");
84-
set({ user: null, isLoggedIn: false });
85-
} catch (error) {
86-
console.error("로그아웃 중 에러가 발생했습니다.", error);
87-
}
88-
},
89-
}),
90-
{
91-
name: "auth-storage",
79+
logout: async () => {
80+
try {
81+
await proxy.post("/api/auth/sign-out");
82+
set({ user: null, isLoggedIn: false });
83+
} catch (error) {
84+
console.error("로그아웃 중 에러가 발생했습니다.", error);
9285
}
93-
)
94-
);
86+
},
87+
}));
9588

9689
export default useAuthStore;

0 commit comments

Comments
 (0)