-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
The current documentation for server-side rendering only mentions sending a 404 response as a last resort: when there is no other error
, the router doesn't know of a redirectLocation
, or if there are no renderProps
to pass to the RouterContext
. However, there is another case that falls under the scope of React Router.
Consider this: what if an app needs to render content at a globbed path? (Example <Route path='*'></Route>
). If the requested content no longer exists at that path (or the API call to retrieve the data required to render fails), current best practices have users redirecting to a <NotFound />
route. This behavior can wreak havoc on the SEO of server pre-rendered applications, and undermine one of the main reasons for using React in the first place.
As the initial request comes in, well before the client has bootstrapped, we should have an option to load up any required data, and return a 404 error code.