Skip to content

Commit

Permalink
add redirect from 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
svehe committed Sep 14, 2023
1 parent 9951237 commit bfc3529
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
text-align: center;
}
</style>
<script>
window.onload=function(){
window.location.replace(window.location.origin + `?redirect=${window.location.path}`);
}
</script>
</head>
<body>
<main>
Expand Down
9 changes: 7 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import React, { useEffect } from 'react';
import { Outlet, useNavigate } from 'react-router-dom';
import { Outlet, useNavigate, useSearchParams } from 'react-router-dom';

import TopAppBar from './app-bar';
import { GlobalService } from './services';
import { isMobile } from 'react-device-detect';

const App = () => {
const navigate = useNavigate();
const [searchParams] = useSearchParams();

useEffect(() => {
if (isMobile) {
navigate('/mobile');
}
const redirect = searchParams.get('redirect');
if(redirect) {
navigate(redirect);
}
}, []);

return (
<div style={{ width: '100%', height: '100%' }}>
<TopAppBar></TopAppBar>
Expand Down

0 comments on commit bfc3529

Please sign in to comment.