-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
Because this site is deployed to GitHub Pages, which doesn't support client-side routing, this file is used to handle the anticipated 404 errors thrown when a user tries to access any page that's not the root. This file forces a redirect to index.html, which is the entry point of the React app, so that react-router-dom can handle the routing on the client side... | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="refresh" content="0; url=./index.html" /> | ||
<script> | ||
//...this script is for redirecting to the index.html page if the user tries to access a page that does not exist, thereby ensuring that react-router-dom is handling routing on the client side because GitHub Pages does not support client-side routing... | ||
var pathname = window.location.pathname | ||
if (pathname !== '/') { | ||
//...if the current path is not the root, redirect to index.html so that react-router-dom can handle the routing | ||
window.location.replace('/index.html') | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<!-- | ||
...The body is intentionally left empty as the user will be redirected immediately | ||
--> | ||
</body> | ||
</html> |