Skip to content

Commit a019092

Browse files
committed
#26 feat: axios 인터셉터 설정
1 parent 6e3e500 commit a019092

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

frontend/src/utils/axios.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,18 @@ const instance = axios.create({
77
},
88
});
99

10+
// accessToken 인터셉터
11+
instance.interceptors.request.use(
12+
(config) => {
13+
if (typeof window !== "undefined") {
14+
const token = localStorage.getItem("accessToken");
15+
if (token) {
16+
config.headers.Authorization = `Bearer ${token}`;
17+
}
18+
}
19+
return config;
20+
},
21+
(error) => Promise.reject(error)
22+
);
23+
1024
export default instance;

0 commit comments

Comments
 (0)