diff --git a/src/components/BackButton.tsx b/src/components/BackButton.tsx index f0cebcdb..b0567a37 100644 --- a/src/components/BackButton.tsx +++ b/src/components/BackButton.tsx @@ -20,7 +20,17 @@ const BackButton: React.FC = ({ const navigate = useNavigate(); const location = useLocation(); const state = (location.state as { backTo?: string }) || {}; - const canGoBack = typeof window !== 'undefined' && window.history.length > 1; + const canGoBack = (() => { + if (typeof window === 'undefined') return false; + if (window.history.length <= 1) return false; + const ref = document.referrer; + if (!ref) return false; + try { + return new URL(ref).origin === window.location.origin; + } catch { + return false; + } + })(); const handleClick = () => { if (canGoBack) {