Skip to content

Commit

Permalink
fix: redirect to a shared 404 page
Browse files Browse the repository at this point in the history
  • Loading branch information
obeys committed Dec 18, 2024
1 parent 29ba726 commit 15cb6b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
27 changes: 0 additions & 27 deletions src/components/404.ts

This file was deleted.

6 changes: 2 additions & 4 deletions src/controllers/404.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { create404Page } from "../components/404";
export async function load404Page() {
export async function redirectTo404() {
const contentArea = document.getElementById("content-area");

if (contentArea) {
try {
const content = create404Page();
contentArea.innerHTML = content;
window.location.href = "https://dao.ubq.fi/404";
} catch (error) {
console.error("Failed to load 404 page:", error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { loadPage1 } from "./controllers/page1";
import { loadPage2 } from "./controllers/page2";
import { load404Page } from "./controllers/404";
import { redirectTo404 } from "./controllers/404";
import { loadHomePage } from "./controllers/home";

// URL Path based routing
Expand All @@ -25,7 +25,7 @@ export async function handleRouting() {
break;
default:
// Redirect to 404 page if no route matches
await load404Page();
await redirectTo404();
break;
}
}
Expand Down

0 comments on commit 15cb6b8

Please sign in to comment.