diff --git a/src/App.tsx b/src/App.tsx index 175c94a0..28bea8f1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -37,9 +37,18 @@ const ProtectedRoute = ({ children }: { children: JSX.Element }) => { useEffect(() => { const checkAuth = async () => { - const currentUserId = getCurrentUserId(); - const response = await getUserInfoApi(currentUserId); - setIsAuthenticated(response.isSuccess); + try { + const currentUserId = getCurrentUserId(); + if (!currentUserId) { + setIsAuthenticated(false); + return; + } + + const response = await getUserInfoApi(currentUserId); + setIsAuthenticated(response.isSuccess); + } catch (error) { + setIsAuthenticated(false); + } }; checkAuth(); }, []);