Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed redirect to /404 when page not found #17

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ app
.route("/register", registerController)
.route("/habits", habitsController)
.route("/api", apiController)
.get("/404", ({ html }) => {
return html(<NotFoundPage />);
})
.onError((err, c) => {
console.error(err);
return c.text("An Error occured", 500);
})
.notFound(({ redirect }) => {
return redirect("/404");
.notFound((ctx) => {
ctx.header("HX-Retarget", "body");
ctx.header("HX-Reswap", "outerHTML");
return ctx.html(<NotFoundPage />);
});

console.log(process.env.NODE_ENV);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/404.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RootLayout } from "$components/layouts.component";
export function NotFoundPage() {
return (
<RootLayout title="404 Not Found">
<section class="h-full flex flex-col gap-y-8">
<div class="h-full flex flex-col gap-y-8">
<div class={"flex flex-col gap-y-4"}>
<Headings>
<a href="/">
Expand All @@ -14,9 +14,9 @@ export function NotFoundPage() {
<hr />
</div>
<div class="h-full w-full flex items-center justify-center">
<p class="text-2xl">Sorry, we didn't find the page you are looking for :(</p>
<p class="text-2xl">Sorry, we didn't find the page you are looking for :(</p>
</div>
</section>
</div>
</RootLayout>
);
}
Loading