From 6843d2db362077319911b20c591ecf5e50eec627 Mon Sep 17 00:00:00 2001 From: Unchained Date: Wed, 1 Apr 2026 10:21:33 +0200 Subject: [PATCH] fix(404): add redirects for broken URLs and custom not-found page - Add permanent redirects for /products/manoon to /products - Strip malformed /contact suffix from product URLs - Create custom branded 404 page with product navigation - Add NotFound translations for en and sr locales --- next.config.ts | 26 +++++++++++++ src/app/[locale]/not-found.tsx | 68 ++++++++++++++++++++++++++++++++++ src/i18n/messages/en.json | 8 ++++ src/i18n/messages/sr.json | 8 ++++ 4 files changed, 110 insertions(+) create mode 100644 src/app/[locale]/not-found.tsx diff --git a/next.config.ts b/next.config.ts index 19fb2fa..241eff8 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,6 +5,32 @@ const withNextIntl = createNextIntlPlugin(); const nextConfig: NextConfig = { output: 'standalone', + async redirects() { + return [ + // Fix malformed URLs with /contact appended to product slugs + { + source: '/:locale(en|sr)/products/:slug*/contact', + destination: '/:locale/products/:slug*', + permanent: true, + }, + { + source: '/products/:slug*/contact', + destination: '/products/:slug*', + permanent: true, + }, + // Redirect old/removed product "manoon" to products listing + { + source: '/:locale(en|sr)/products/manoon', + destination: '/:locale/products', + permanent: true, + }, + { + source: '/products/manoon', + destination: '/products', + permanent: true, + }, + ]; + }, async rewrites() { const rybbitHost = process.env.NEXT_PUBLIC_RYBBIT_HOST || "https://rybbit.nodecrew.me"; return [ diff --git a/src/app/[locale]/not-found.tsx b/src/app/[locale]/not-found.tsx new file mode 100644 index 0000000..305e0d7 --- /dev/null +++ b/src/app/[locale]/not-found.tsx @@ -0,0 +1,68 @@ +"use client"; + +import { useTranslations, useLocale } from "next-intl"; +import Header from "@/components/layout/Header"; +import Footer from "@/components/layout/Footer"; +import Link from "next/link"; +import { Home, Search, Package } from "lucide-react"; + +export default function NotFoundPage() { + const t = useTranslations("NotFound"); + const locale = useLocale(); + const basePath = `/${locale}`; + + return ( + <> +
+
+
+
+ {/* 404 Code */} +
+ 404 +
+ +

+ {t("title")} +

+

+ {t("description")} +

+ + {/* Quick Links */} +
+ + + {t("browseProducts")} + + + + {t("goHome")} + +
+ + {/* Search Suggestion */} +
+
+ + + {t("lookingFor")} + +
+

+ {t("searchSuggestion")} +

+
+
+
+
+