Skip to content

Commit

Permalink
add react router redirect and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
goldensunliu authored and okendoken committed Feb 29, 2016
1 parent ba95342 commit 1785a23
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server.js
Expand Up @@ -84,6 +84,14 @@ server.use('/graphql', expressGraphQL(req => ({
server.get('*', async (req, res, next) => {
try {
match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
if (error) {
throw error;
}
if (redirectLocation) {
const redirectPath = `${redirectLocation.pathname}${redirectLocation.search}`;
res.redirect(302, redirectPath);
return;
}
let statusCode = 200;
const data = { title: '', description: '', css: '', body: '', entry: assets.main.js };
const css = [];
Expand Down

0 comments on commit 1785a23

Please sign in to comment.