diff --git a/src/hooks/auth/useAuth/index.ts b/src/hooks/auth/useAuth/index.ts index 447f3a79..120fcd9c 100644 --- a/src/hooks/auth/useAuth/index.ts +++ b/src/hooks/auth/useAuth/index.ts @@ -1,6 +1,6 @@ import { shallow } from 'zustand/shallow'; import useAuthStore from './store'; -import axiosInstance from '@libs/api/client'; +import axiosInstance, { setAccessToken } from '@libs/api/client'; import { demoStart, getAccountMe } from '@libs/api/auth'; import { useLocation, useNavigate } from 'react-router'; import ROUTE from '@libs/constant/path'; @@ -87,6 +87,12 @@ const useAuth = (activeEffect = false) => { setState('isAuth', true); }; + useEffect(() => { + if (accessToken) { + setAccessToken(accessToken); + } + }, [accessToken]); + useEffect(() => { if (_loaded && activeEffect) { if (demoStartDate && new Date(demoStartDate).getTime() + 3540000 - new Date().getTime() <= 0)