Closed keyeh closed 8 years ago
@keyeh that's a good point - actually the final else I think is never called right? I remember you doing a fix to pass store to it, but I think it's never called?
else {
handle404(res, store);
}
It's possible to check if the route.path === '*' or route.component === NoMatch but it's too dependent on the structure of Routes.js
to be a general solution - e.g. https://github.com/DominicTobias/universal-react/pull/19
@DominicTobias Yes the final else is never called unless you remove the catch all route.
Routes.js
structure? As long as there's a *
route it should work, right?Maybe checking the component instead of the route is better.
function routeIsUnmatched(renderProps) {
return renderProps.components.indexOf(NoMatch) !== -1;
}
Now rendering NoMatch
component will always cause a 404.
I was wondering if it was possible to nest the *
path (probably not), or nest more routes inside of it so that it's not the last one (probably) so indexOf is a good idea 👍
Going to go with *
as then it's not dependent on a particular component, I don't think you can actually nest routes inside *
anyway as that wouldn't make sense, and it seems to ignore IndexRoute
inside
When a page is not found the response from the server is an HTTP 200 instead of 404.
Example:
http://localhost:3000/asdf
returns 200 statusRemoving
<Route path="*" component={NoMatch} />
in Routes.js fixes this, but theNoMatch
component doesn't render correctly (it should render as a child ofApp
component)