From 5afe6e52a3b8a635002bcb1cdd41c5eece9f17b9 Mon Sep 17 00:00:00 2001 From: Zahra Bayat Date: Fri, 1 Nov 2024 20:44:07 +0330 Subject: [PATCH] Fix 404 github pages error --- index.html | 22 +++++++++++++++++++--- package.json | 1 + public/404.html | 32 ++++++++++++++++++++++++++++++++ src/router.tsx | 6 +----- 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 public/404.html diff --git a/index.html b/index.html index 5982052..1c2c89f 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -7,13 +7,29 @@ To Do App diff --git a/package.json b/package.json index 84ad8c9..2d22014 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "to-do-app", + "homepage": "https://zahrabayatt.github.io/to-do-app/", "private": true, "version": "0.0.0", "type": "module", diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..e38e7ab --- /dev/null +++ b/public/404.html @@ -0,0 +1,32 @@ + + + + + React Router + + + + diff --git a/src/router.tsx b/src/router.tsx index 23b3cc3..5774102 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -9,10 +9,10 @@ import TasksPage from "./pages/TasksPage"; import CategoriesPage from "./pages/CategoriesPage"; import TasksPageSearch from "./types/TasksPageSearch"; -// Root route that wraps everything const rootRoute = createRootRoute({ component: Layout, errorComponent: ErrorPage, + notFoundComponent: ErrorPage, }); const tasksRoute = createRoute({ @@ -32,17 +32,13 @@ const categoriesRoute = createRoute({ component: CategoriesPage, }); -// Build the route tree const routeTree = rootRoute.addChildren([tasksRoute, categoriesRoute]); -// Create the router instance const router = createRouter({ routeTree: routeTree, basepath: import.meta.env.BASE_URL, - defaultNotFoundComponent: ErrorPage, }); -// Register the router type declare module "@tanstack/react-router" { interface Register { router: typeof router;