Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Return 404 instead of 500 for unmatched landing paths containing a dot (#2965)
Luke Vella2a1c59fc019d
diff --git a/apps/landing/public/apple-touch-icon-precomposed.png b/apps/landing/public/apple-touch-icon-precomposed.pngnew file mode 100644index 000000000..c96aa0973Binary files /dev/null and b/apps/landing/public/apple-touch-icon-precomposed.png differdiff --git a/apps/landing/public/apple-touch-icon.png b/apps/landing/public/apple-touch-icon.pngnew file mode 100644index 000000000..c96aa0973Binary files /dev/null and b/apps/landing/public/apple-touch-icon.png differdiff --git a/apps/landing/src/app/not-found.tsx b/apps/landing/src/app/not-found.tsxnew file mode 100644index 000000000..1da813795--- /dev/null+++ b/apps/landing/src/app/not-found.tsx@@ -0,0 +1,42 @@+import { buttonVariants } from "@rallly/ui";+import { FileSearchIcon } from "lucide-react";+import type { Metadata } from "next";+import "./[locale]/globals.css";+import { sans } from "@/fonts/sans";++export const metadata: Metadata = {+ title: "404 not found",+ description: "The page you are looking for does not exist.",+};++// Renders outside the [locale] segment, so there is no locale and no+// I18nProvider to read from. Copy is hardcoded English.+export default function NotFound() {+ return (+ <html lang="en" className={sans.className}>+ <body>+ <div className="inset-0 flex h-full w-full items-center justify-center lg:absolute">+ <div className="space-y-8">+ <div className="space-y-4">+ <FileSearchIcon className="mb-4 inline-block size-24 text-gray-400" />+ <div className="mb-2 font-bold text-3xl text-primary">+ 404 not found+ </div>+ <p className="text-gray-600">+ We couldn't find the page you're looking for.+ </p>+ </div>+ <div className="flex space-x-3">+ <a href="/" className={buttonVariants({ variant: "primary" })}>+ Go to home+ </a>+ <a href="https://support.rallly.co" className={buttonVariants()}>+ Support+ </a>+ </div>+ </div>+ </div>+ </body>+ </html>+ );+}diff --git a/apps/landing/src/i18n/server.ts b/apps/landing/src/i18n/server.tsindex 955a83c0d..5fd319d06 100644--- a/apps/landing/src/i18n/server.ts+++ b/apps/landing/src/i18n/server.ts@@ -1,11 +1,19 @@import type { Namespace } from "i18next";-import { defaultNS, fallbackLng } from "@/i18n/settings";+import { notFound } from "next/navigation";+import { defaultNS, fallbackLng, languages } from "@/i18n/settings";import { i18next } from "./i18next";export async function getTranslation<Ns extends Namespace>(locale: string = fallbackLng,ns: string | string[] = defaultNS,) {+ // The proxy skips paths containing a dot, so they reach [locale] with the raw+ // path as the locale, e.g. "ads.txt". Rendering those downstream throws a+ // RangeError from Intl, surfacing as a 500 instead of a 404.+ if (!languages.includes(locale)) {+ notFound();+ }+const lng = locale;if (lng && i18next.resolvedLanguage !== lng) {await i18next.changeLanguage(lng);