File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta http-equiv ="refresh " content ="0; url=./index.html " />
5
+ < script type ="text/javascript ">
6
+ var pathname = window . location . pathname ;
7
+ window . location . href = window . location . origin + '/index.html?redirect=' + pathname ;
8
+ </ script >
9
+ </ head >
10
+ < body > </ body >
11
+ </ html >
Original file line number Diff line number Diff line change 6
6
Routes ,
7
7
Route ,
8
8
Navigate ,
9
+ useLocation
9
10
} from 'react-router-dom' ;
10
11
11
12
import Login from './components/login' ;
@@ -30,9 +31,21 @@ function App() {
30
31
31
32
return ( ) => unsubscribe ( ) ; // Clean up on unmount
32
33
} , [ ] ) ;
34
+ // Handle redirects from GitHub Pages 404 fallback
35
+ function RedirectWithState ( ) {
36
+ const location = useLocation ( ) ;
37
+ useEffect ( ( ) => {
38
+ const redirectPath = new URLSearchParams ( location . search ) . get ( 'redirect' ) ;
39
+ if ( redirectPath ) {
40
+ window . history . replaceState ( { } , '' , redirectPath ) ;
41
+ }
42
+ } , [ location ] ) ;
43
+ return null ;
44
+ }
33
45
34
46
return (
35
47
< Router >
48
+ < RedirectWithState />
36
49
< div className = "App" >
37
50
{ /* Pass user status as loggedin prop to Navbar */ }
38
51
< Navbar loggedin = { user ? 'true' : 'false' } />
You can’t perform that action at this time.
0 commit comments