Skip to content

Commit 519c320

Browse files
committed
fixed reloading
1 parent 3ca4291 commit 519c320

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

public/404.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta http-equiv="refresh" content="0; url=./" />
4+
<meta charset="utf-8" />
5+
<title>Redirecting...</title>
6+
<script type="text/javascript">
7+
// Redirect all paths (like /leaderboard) back to index.html,
8+
// but preserve the original path for React Router.
9+
const redirectTo = window.location.protocol + '//' + window.location.host + '/?' +
10+
'p=' + window.location.pathname + window.location.search + window.location.hash;
11+
window.location.replace(redirectTo);
12+
</script>
513
</head>
6-
<body></body>
14+
<body>
15+
</body>
716
</html>

public/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4+
<script type="text/javascript">
5+
// If we came here via the redirect above, rewrite the URL back
6+
// to the original path so React Router can pick it up.
7+
(function() {
8+
const params = new URLSearchParams(window.location.search);
9+
const redirectPath = params.get('p');
10+
if (redirectPath) {
11+
window.history.replaceState({}, '', redirectPath);
12+
}
13+
})();
14+
</script>
415
<meta charset="utf-8" />
516
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
617
<meta name="viewport" content="width=device-width, initial-scale=1" />

0 commit comments

Comments
 (0)