Skip to content

Commit

Permalink
feat: handle 404 PE-5161
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen committed Dec 8, 2023
1 parent c6bd0a4 commit 6403b16
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,14 @@
<body>
<div id="root"></div>
<script type="module" src="src/main.tsx"></script>
<script>
(() => {
const redirect = sessionStorage.redirect;
delete sessionStorage.redirect;
if (redirect && redirect !== location.href) {
history.replaceState(null, null, redirect);
}
})();
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"type": "module",
"description": "ArDrive Turbo App",
"homepage": "https://ardriveapp.github.io/turbo-app",
"homepage": "./",
"license": "AGPL-3.0-or-later",
"author": {
"name": "Permanent Data Solutions Inc",
Expand Down
13 changes: 13 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Page Not Found</title>
<script>
sessionStorage.redirect = location.href;
</script>
<meta http-equiv="refresh" content="0;URL='/'" />
</head>
<body></body>
</html>
8 changes: 8 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ export default defineConfig({
define: {
"import.meta.env.PACKAGE_VERSION": JSON.stringify(packageJson.version),
},
build: {
rollupOptions: {
input: {
main: "index.html",
404: "public/404.html",
},
},
},
});

0 comments on commit 6403b16

Please sign in to comment.