Skip to content

Commit

Permalink
add spa redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed Jun 21, 2024
1 parent 6dd72ea commit f713957
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>
<body>
<script type="text/javascript">
/** redirect to root and pass page to router */
console.debug("Redirecting from:", window.location);
const { origin, pathname, search, hash } = window.location;
window.sessionStorage.redirect = pathname + search + hash;
window.location = "/";
</script>
</body>
</html>
14 changes: 13 additions & 1 deletion app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ import PageHome from "./pages/PageHome.vue";
import "./styles.css";

const routes = [
{ path: "/", component: PageHome },
{
name: "Home",
path: "/",
component: PageHome,
beforeEnter: () => {
const url = window.sessionStorage.redirect as string;
if (url) {
console.debug("Redirecting to:", url);
window.sessionStorage.removeItem("redirect");
return url;
}
},
},
{ path: "/core-projects", component: PageCoreProjects },
{ path: "/core-project/:id", component: PageCoreProject },
];
Expand Down

0 comments on commit f713957

Please sign in to comment.