diff --git a/frontend/public/404.html b/frontend/public/404.html
index e11507c..8b5f35c 100644
--- a/frontend/public/404.html
+++ b/frontend/public/404.html
@@ -1,11 +1,14 @@
+
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index be19f9e..896d23e 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -14,6 +14,7 @@ import {
useMatches,
useRouteLoaderData,
} from "react-router-dom";
+import { isEmpty } from "lodash";
import Footer from "@/components/Footer";
import Header from "@/components/Header";
import TableOfContents from "@/components/TableOfContents";
@@ -77,11 +78,15 @@ const routes = [
element: ,
loader: async () => {
/** handle 404 redirect */
- const url = window.sessionStorage.redirect as string;
- if (url) {
- console.debug("Redirecting to:", url);
- window.sessionStorage.removeItem("redirect");
- return redirect(url);
+ const path = window.sessionStorage.redirectPath || "";
+ const state = JSON.parse(window.sessionStorage.redirectState || "{}");
+ if (!isEmpty(state)) window.history.replaceState(state, "");
+ if (path) {
+ console.debug("Redirecting to:", path);
+ console.debug("With state:", state);
+ window.sessionStorage.removeItem("redirectPath");
+ window.sessionStorage.removeItem("redirectState");
+ return redirect(path);
} else return null;
},
},