"use client"; import { useEffect } from "react"; import { useAuthStore } from "@/stores/auth-store"; import { getPathPrefix } from "@/lib/browser-navigation"; export default function NotFound() { const isAuthenticated = useAuthStore((s) => s.isAuthenticated); useEffect(() => { if (!isAuthenticated) { const prefix = getPathPrefix(); // Don't redirect admin routes to the webmail login page. Admin paths // are mounted relative to the deployment prefix, so account for it. const adminBase = `${prefix}/admin`; const isAdminRoute = window.location.pathname === adminBase || window.location.pathname.startsWith(`${adminBase}/`); if (!isAdminRoute) { window.location.href = `${prefix}/login`; } } }, [isAuthenticated]); if (!isAuthenticated) { let isAdmin = false; if (typeof window !== 'undefined') { const prefix = getPathPrefix(); const adminBase = `${prefix}/admin`; isAdmin = window.location.pathname === adminBase || window.location.pathname.startsWith(`${adminBase}/`); } if (!isAdmin) return null; } const prefix = typeof window !== 'undefined' ? getPathPrefix() : ''; return (

404

This page could not be found.

Go home
); }