Skip to content

Commit ea7ee19

Browse files
authored
prod reload 404 fix -- need to test in prod (#52)
* prod reload 404 fix -- need to test in prod * fix conflict?
1 parent 554f346 commit ea7ee19

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

404.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>WCS Points</title>
6+
<script type="text/javascript">
7+
// handles redirects for single page apps on GitHub Pages
8+
var segmentCount = 0;
9+
var location = window.location;
10+
11+
// redirect to the index.html with a special query parameter containing the path
12+
location.replace(
13+
location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') +
14+
'/' +
15+
'?path=' +
16+
location.pathname.slice(1).split('/').slice(segmentCount).join('/') +
17+
(location.search || '') +
18+
(location.hash || '')
19+
);
20+
</script>
21+
</head>
22+
<body>
23+
Redirecting...
24+
</body>
25+
</html>

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
<link rel="icon" type="image/svg+xml" href="./src/assets/logo-icon.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>WCS Points</title>
8+
<script type="text/javascript">
9+
// Thandles the redirect from 404.html
10+
(function() {
11+
var path = window.location.search.match(/path=([^&]*)/);
12+
if (path) {
13+
var originalPath = path[1];
14+
var search = window.location.search.replace(/path=[^&]*(&|$)/, '');
15+
search = search === '?' ? '' : search;
16+
17+
window.history.replaceState(null, null,
18+
'/' + originalPath +
19+
(search || '') +
20+
(window.location.hash || '')
21+
);
22+
}
23+
})();
24+
</script>
825
</head>
926
<body>
1027
<div id="root"></div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"prepare": "husky install",
1212
"prettier-format": "prettier --config .prettierrc --write",
1313
"predeploy": "npm run build",
14-
"deploy": "gh-pages -b main -d build"
14+
"deploy": "gh-pages -b main -d dist"
1515
},
1616
"husky": {
1717
"hooks": {

0 commit comments

Comments
 (0)