Skip to content

Commit ed7e411

Browse files
jwaldripclaude
andcommitted
fix: suppress 404 flash on browse redirect — render nothing during SPA fallback
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5bd352e commit ed7e411

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

website/app/not-found.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
"use client"
22

3-
import { useEffect } from "react"
3+
import { useEffect, useState } from "react"
44
import Link from "next/link"
55

66
export default function NotFound() {
7+
const [redirecting, setRedirecting] = useState(false)
8+
79
useEffect(() => {
8-
// SPA fallback: if the path starts with /browse/, redirect to /browse/ with the path saved
9-
// so the browse page can restore the full path-based URL
1010
const path = window.location.pathname
1111
if (path.startsWith("/browse/") && path !== "/browse/") {
12+
setRedirecting(true)
1213
sessionStorage.setItem("browse-redirect-path", path + window.location.search)
1314
window.location.replace("/browse/")
1415
}
1516
}, [])
1617

18+
if (redirecting) return null
19+
1720
return (
1821
<div className="flex min-h-[60vh] flex-col items-center justify-center px-4">
1922
<h1 className="mb-2 text-6xl font-bold text-stone-300 dark:text-stone-700">404</h1>

0 commit comments

Comments
 (0)