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 18, 2016
1 parent 8038fda commit 2074e5a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server.js
Expand Up @@ -37,6 +37,14 @@ server.use('/api/content', require('./api/content').default);
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 2074e5a

Please sign in to comment.