Skip to content

Commit

Permalink
Refactor: 토큰 불러오는 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hongjw030 committed Dec 18, 2023
1 parent 9aa07ca commit d860374
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/api/axiosInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export const axiosInstance = axios.create({

axiosInstance.interceptors.request.use((config) => {
if (!config.headers) return config;
const accessToken = localStorage.getItem("accessToken") || "";
if (accessToken && config.headers) {
config.headers["Authorization"] = accessToken;
if (typeof window !== "undefined") {
const accessToken = localStorage.getItem("accessToken");
if (accessToken && config.headers) {
config.headers["Authorization"] = accessToken;
}
}
return config;
});
Expand Down

0 comments on commit d860374

Please sign in to comment.