Flutter Web 404 Pages Can Crash Silently While Servers Return Wrong Status Codes
A Flutter web developer discovered that their 404 error page had been silently crashing for an extended period, masked by a Firebase Hosting misconfiguration that returned HTTP 200 instead of 404 for missing routes. The catch-all rewrite rule was serving the 404 page with a success status, creating so-called soft 404s that misled search crawlers into indexing non-existent pages. The actual page crash stemmed from a go_router bug where the errorBuilder renders outside any RouteBase context, making GoRouterState.of(context) throw an unconditional error with no nullable fallback available. The fix involved removing the catch-all rewrite rule so the server returns genuine 404 status codes, and falling back to Uri.base.path in a try-catch block when GoRouterState is unavailable. The author notes the two bugs concealed each other — the status-code fix prompted someone to actually visit the page, which is what finally exposed the rendering crash.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in