Skip to content

Commit 9423c79

Browse files
committed
fixed File not found on github
1 parent bc01926 commit 9423c79

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎frontend/src/provider/tanstack-router.provider.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { routeTree } from "@/routeTree.gen";
22
import { createRouter, RouterProvider } from "@tanstack/react-router";
33

4+
// Handle GitHub Pages 404.html redirect
5+
// When 404.html redirects to index.html, restore the original path
6+
const redirectPath = sessionStorage.getItem('redirect');
7+
if (redirectPath && redirectPath !== window.location.pathname + window.location.search + window.location.hash) {
8+
sessionStorage.removeItem('redirect');
9+
// Restore the path (from 404.html) before router initializes
10+
// redirectPath already includes pathname, query, and hash
11+
window.history.replaceState(null, '', redirectPath);
12+
}
13+
414
const basepath = import.meta.env.BASE_URL; // auto matches Vite base
515
console.log({basepath});
616

0 commit comments

Comments
 (0)