Skip to content

Commit

Permalink
Fix: accessToken 가져오는 방식 수정
Browse files Browse the repository at this point in the history
- 로컬 스토리지에서 파싱하지 않고 zustand의 메서드를 활용해 데이터 가져오도록 수정
  • Loading branch information
sscoderati committed Jan 12, 2024
1 parent 2c392cd commit ac74e48
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/apis/axios.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import axios from "axios";
import useAuthStore from "@/store/AuthStore.tsx";

type AuthStoreState = {
authTokens: {
accessToken: string;
refreshToken: string;
};
userId: number;
};

const { state }: { state: AuthStoreState } = JSON.parse(localStorage.getItem("auth-store") || "{}");
const tokens = useAuthStore.getState().authTokens;

export const axiosAPI = axios.create({
baseURL:
process.env.NODE_ENV === "development"
? "http://localhost:5173"
: import.meta.env.VITE_BASE_URL,
headers: {
Authorization: `${state.authTokens.accessToken}`,
Authorization: `${tokens?.accessToken}`,
},
});

Expand Down

0 comments on commit ac74e48

Please sign in to comment.