Spaces:
Runtime error
Runtime error
File size: 341 Bytes
c5cf697 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import { Navigate, useLocation } from 'react-router-dom'
import { getAccessToken } from './storage'
export default function RequireAuth({ children }) {
const location = useLocation()
const token = getAccessToken()
if (!token) {
return <Navigate to="/login" replace state={{ from: location.pathname }} />
}
return children
}
|