Skip to content

Full Toolkit for Next-Level Domain Analysis

Add custom 404 pages 🙈

Felix Wotschofskyc87202ab1667
diff --git a/app/lookup/[domain]/layout.tsx b/app/lookup/[domain]/layout.tsx
index 1f064bf..a883753 100644
--- a/app/lookup/[domain]/layout.tsx
+++ b/app/lookup/[domain]/layout.tsx
@@ -1,5 +1,6 @@
import { ExternalLinkIcon } from 'lucide-react';
import type { Metadata } from 'next';
+import { notFound } from 'next/navigation';
import { type FC, type ReactNode, Suspense } from 'react';
import RelatedDomains from '@/components/RelatedDomains';
@@ -8,6 +9,7 @@ import SearchForm from '@/components/SearchForm';
import WhoisQuickInfo, {
WhoisQuickInfoPlaceholder,
} from '@/components/WhoisQuickInfo';
+import isValidDomain from '@/utils/isValidDomain';
type LookupLayoutProps = {
children: ReactNode;
@@ -37,6 +39,10 @@ const LookupLayout: FC<LookupLayoutProps> = ({
children,
params: { domain },
}) => {
+ if (!isValidDomain(domain)) {
+ return notFound();
+ }
+
return (
<>
<div className="container mb-8 max-w-xl">
diff --git a/app/lookup/not-found.tsx b/app/lookup/not-found.tsx
new file mode 100644
index 0000000..1199ceb
--- /dev/null
+++ b/app/lookup/not-found.tsx
@@ -0,0 +1,12 @@
+import { type FC } from 'react';
+
+const LookupNotFound: FC = () => (
+ <div className="mt-12 flex flex-col items-center gap-2">
+ <h2>404 - Not Found</h2>
+ <p className="mt-2 text-center text-sm text-muted-foreground">
+ Not a valid domain
+ </p>
+ </div>
+);
+
+export default LookupNotFound;
diff --git a/app/not-found.tsx b/app/not-found.tsx
new file mode 100644
index 0000000..5a9966b
--- /dev/null
+++ b/app/not-found.tsx
@@ -0,0 +1,12 @@
+import { type FC } from 'react';
+
+const GlobalNotFound: FC = () => (
+ <div className="mt-12 flex flex-col items-center gap-2">
+ <h2>404 - Not Found</h2>
+ <p className="mt-2 text-center text-sm text-muted-foreground">
+ This page doesn&apos;t exist
+ </p>
+ </div>
+);
+
+export default GlobalNotFound;