()
| 3 | import axios from 'axios'; |
| 4 | |
| 5 | const ValidateAuth: React.FC = () => { |
| 6 | const {setIsAuth, setUser, setIsLoading} = useAuthStore(); |
| 7 | useEffect(() => { |
| 8 | const checkAuth = async () => { |
| 9 | try { |
| 10 | const res = await axios.get( |
| 11 | `${import.meta.env.VITE_SERVER_URL}/auth/me`, |
| 12 | { |
| 13 | withCredentials: true, |
| 14 | } |
| 15 | ); |
| 16 | if (res.status === 200) { |
| 17 | setIsAuth(true); |
| 18 | setUser(res.data); |
| 19 | setIsLoading(false); |
| 20 | } |
| 21 | } catch (error) { |
| 22 | setIsLoading(false); |
| 23 | } |
| 24 | }; |
| 25 | checkAuth(); |
| 26 | }, [setIsAuth, setIsLoading, setUser]); |
| 27 | return <></>; |
| 28 | }; |
| 29 | export default ValidateAuth; |
nothing calls this directly
no test coverage detected