diff --git a/generators/app/templates/src/server.js b/generators/app/templates/src/server.js index ac0d594..77779f0 100755 --- a/generators/app/templates/src/server.js +++ b/generators/app/templates/src/server.js @@ -60,30 +60,30 @@ app.use((req, res) => { // Match the state of the store to the router and respond match({ history, routes: routes(history, store), location: req.originalUrl }, (error, redirectLocation, renderProps) => { - loadOnServer({...renderProps, store, helpers: {client}}).then(() => { - if (redirectLocation) { - res.redirect(redirectLocation.pathname + redirectLocation.search); - } else if (error) { - console.error('ROUTER ERROR:', pretty.render(error)); - res.status(500); - hydrateOnClient(); - } else if (renderProps) { - const component = ReactDOM.renderToString( - - - - ); + if (redirectLocation) { + res.redirect(redirectLocation.pathname + redirectLocation.search); + } else if (error) { + console.error('ROUTER ERROR:', pretty.render(error)); + res.status(500); + hydrateOnClient(); + } else if (renderProps) { + loadOnServer({...renderProps, store, helpers: {client}}).then(() => { + const component = ReactDOM.renderToString( + + + + ); - global.navigator = {userAgent: req.headers['user-agent']}; + global.navigator = {userAgent: req.headers['user-agent']}; - res.status(200); + res.status(200); - res.send('\n' + - ReactDOM.renderToStaticMarkup()); - } else { - res.status(404).send('Not found'); - } - }); + res.send('\n' + + ReactDOM.renderToStaticMarkup()); + }); + } else { + res.status(404).send('Not found'); + } }); });