Skip to content

Commit 651f954

Browse files
committed
add redirect file to properly run spa in github pages
1 parent eda5402 commit 651f954

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>SampleMed Regional Portal</title>
8+
<!-- Single Page Apps for GitHub Pages redirect handler -->
9+
<script type="text/javascript">
10+
(function(l) {
11+
if (l.search[1] === '/' ) {
12+
var decoded = l.search.slice(1).split('&').map(function(s) {
13+
return s.replace(/~and~/g, '&')
14+
}).join('?');
15+
window.history.replaceState(null, null,
16+
l.pathname.slice(0, -1) + decoded + l.hash
17+
);
18+
}
19+
}(window.location))
20+
</script>
821
</head>
922
<body>
1023
<div id="root"></div>

public/404.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Redirecting...</title>
6+
<script>
7+
// Single Page Apps for GitHub Pages
8+
// https://github.com/rafgraph/spa-github-pages
9+
var pathSegmentsToKeep = 1;
10+
11+
var l = window.location;
12+
l.replace(
13+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
14+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
15+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
16+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
17+
l.hash
18+
);
19+
</script>
20+
</head>
21+
<body>
22+
Redirecting...
23+
</body>
24+
</html>

0 commit comments

Comments
 (0)