Skip to content

Commit 4ca56df

Browse files
authored
Merge pull request #32 from Western-Formula-Racing/dev-main
Add GitHub Pages redirect support
2 parents 5da3f66 + 9043dff commit 4ca56df

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

pecan/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>pecan-live-dashboard</title>
8+
<script>
9+
// GitHub Pages SPA redirect workaround - restore URL from 404.html
10+
(function(){
11+
var redirect = sessionStorage.redirect;
12+
delete sessionStorage.redirect;
13+
if (redirect && redirect !== location.href) {
14+
history.replaceState(null, null, redirect);
15+
}
16+
})();
17+
</script>
818
</head>
919
<body>
1020
<div id="root"></div>

pecan/public/404.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Redirecting...</title>
6+
<script>
7+
// GitHub Pages SPA redirect workaround
8+
// Store the path and redirect to index.html
9+
sessionStorage.redirect = location.href;
10+
</script>
11+
<meta http-equiv="refresh" content="0;URL='/'">
12+
</head>
13+
<body>
14+
</body>
15+
</html>

pecan/src/routes.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import Settings from "./pages/Settings";
77
import ChargeCart from "./pages/ChargeCart";
88
import MonitorBuilder from "./pages/MonitorBuilder";
99

10+
// Get base path for GitHub Pages deployment
11+
const basename = import.meta.env.BASE_URL || '/';
12+
1013
export const router = createBrowserRouter([
1114
{
1215
path: "/",
@@ -21,4 +24,4 @@ export const router = createBrowserRouter([
2124
{ path: "monitor-builder", element: <MonitorBuilder /> },
2225
],
2326
},
24-
]);
27+
], { basename });

0 commit comments

Comments
 (0)