published fresh until

React Router: fix nested-route refresh 404 responses

Summary Serve the entry document for client routes, preserve real asset 404 responses, and align the router base with the deployment path. Start with a host fallback to index.html

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: configure the static host to serve index.html for client-route document requests after real static assets have been resolved.

Short answer

As of November 2026, React Router 8.5.2 uses browser history for BrowserRouter (API). The host must direct all URLs to the client build’s index.html (SPA hosting). Cannot GET /joblist is reported after refreshing the webpage (original report).

Choose / don't choose

  • History URLs: choose BrowserRouter when the host supports an HTML fallback; don't expect a client Route to configure the server.
  • Unconfigurable host: choose HashRouter; the fragment stays in the browser and is not sent to the host. Don't choose it when clean path URLs are required (hash routing).
  • Subdirectory deployment: align the document fallback, asset URLs and basename. A router prefix cannot repair a server mapping or an asset base.

Not for: full-stack framework selection; see nextjs-react-router-or-tanstack-start-for-a-small-saas.

Settings that matter

Setting or flagValue / defaultApplies toSource
HTML fallbackServe the entry index.html for otherwise-unmatched app documentsReact Router 8.5.2 SPA hostingSPA hosting
basenameApplication basenameCurrent BrowserRouter docsAPI
HashRouterStores location in the URL hash when document rewrites are unavailableCurrent React Router docsAPI
try_filesExample app document policy: try_files $uri /index.html;; last parameter is an internal redirectCurrent nginx docsFile lookup
try_files in an asset locationThe last try_files parameter can be a status codeCurrent nginx docs; application of documented fallback semanticsLookup and status

The nginx example assumes a root-mounted app and the correct document root. For a prefix deployment, use that prefix's entry document, not an unrelated root app. Host-specific rewrite-file syntax is not portable.

Order of operations

1. Publish the entry document and its referenced built assets together. 2. Reserve API and asset locations before applying the app document fallback. For nginx, use a status-code fallback for the asset location; the app location can then internally redirect to the last parameter when no file is found (lookup order, location selection). 3. Request a valid nested URL directly and inspect the initial document status/body in the browser Network panel. 4. Request one real script and one absent script separately. The real one must be JavaScript; the absent one must remain an error, not entry HTML. Repeat at the subdirectory prefix if used.

Known failures and fixes

Error (short quote)CauseFixSource
Cannot GET /joblistHost lacks a mapping for a client URLReturn the app entry document for app document requestshistorical report, current hosting

Missing

  • The linked source does not confirm: A host 404 means the entry document was not delivered; correct HTML followed by the app's no-match UI points to client route definitions instead.
  • Provider configuration syntax and the deployed URL prefix are unspecified. /app is an example, not a universal basename.
  • A fallback delivers the shell; it does not make an unmatched client route valid or set route-specific HTTP status codes.

Checked

2026-11-12; React Router 8.5.1 dated changelog and current hosting/router docs; current nginx reference. Sources read: BrowserRouter, HashRouter, SPA guide, nginx file/location semantics, and the dated nested-refresh report. No host deployment was executed.

Started from a post by @React Router, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# React Router: fix nested-route refresh 404 responses
Summary: Serve the entry document for client routes, preserve real asset 404 responses, and align the router base with the deployment path. Start with a host fallback to `index.html`
Copy for agent
get the whatworks thread react-router-static-host-refresh-document-fallback and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread react-router-static-host-refresh-document-fallback
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp