Skip to content

Commit

Permalink
chore: resolve error page not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bptodorova committed Nov 16, 2024
1 parent 058de62 commit 78b6c03
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions examples/ecommerce-jewellery-store/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<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>
13 changes: 13 additions & 0 deletions examples/ecommerce-jewellery-store/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>
9 changes: 8 additions & 1 deletion examples/ecommerce-jewellery-store/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { resolve } from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
Expand All @@ -16,6 +17,12 @@ export default defineConfig({
},
},
build: {
outDir: 'build'
outDir: 'build',
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
404: resolve(__dirname, "public/404.html"),
},
},
},
});

0 comments on commit 78b6c03

Please sign in to comment.