React-redux-universal-hot-example: Server return status 200 while rendering 404 page

Created on 4 Mar 2016  路  5Comments  路  Source: erikras/react-redux-universal-hot-example

Because of the catch-all route match will always match a route and renderProps will always be defined. For this reason, this branch is never reached and the 404 page is served with a status code of 200.

Most helpful comment

How to pass status for ex for this route: /collection/:id_product ???

All 5 comments

I'm facing the same issue in a project of mine. My current best idea would be to have different routes module on the client, that filters the 404 route. Pseudocode:

//server/routes.js
import routes from '../app/routes';
export default routes.filter(r => r.status !== 400);

Any better ideas?

Turns out we can use renderProps.route to search for a 404 route:

// given a route defined like this:
<Route status={404}/>
// in the match callback we can:
const is404 = renderProps.routes.find(r => r.status === 404) !== undefined;

+1

+1

How to pass status for ex for this route: /collection/:id_product ???

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisabrams picture chrisabrams  路  5Comments

paulinda picture paulinda  路  5Comments

korczis picture korczis  路  3Comments

glennr picture glennr  路  6Comments

yesmeck picture yesmeck  路  3Comments