Spaces:
Runtime error
Runtime error
Download frontend/src/auth/RequireAuth.jsx from cuiconnect/backend: direct link, hf CLI and curl.
- Browser
- Download file 341 Bytes
-
https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/auth/RequireAuth.jsx
- Command line
-
hf download hf://spaces/cuiconnect/backend/frontend/src/auth/RequireAuth.jsx
-
curl -L -o RequireAuth.jsx https://huggingface.co/spaces/cuiconnect/backend/resolve/main/frontend/src/auth/RequireAuth.jsx
341 Bytes
| 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 | |
| } | |