Skip to content

Commit bea0820

Browse files
committed
Update server rendering docs
1 parent 9baf94b commit bea0820

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/guides/advanced/ServerRendering.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import routes from './routes'
2121
serve((req, res) => {
2222
// Note that req.url here should be the full URL path from
2323
// the original request, including the query string.
24-
match(req.url, (error, redirectLocation, renderProps) => {
25-
if (redirectLocation) {
26-
res.redirect(302, redirectLocation.pathname + redirectLocation.search)
27-
} else if (error) {
24+
match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
25+
if (error) {
2826
res.send(500, error.message)
29-
} else if (renderProps == null) {
30-
res.send(404, 'Not found')
31-
} else {
27+
} else if (redirectLocation) {
28+
res.redirect(302, redirectLocation.pathname + redirectLocation.search)
29+
} else if (renderProps) {
3230
res.send(200, renderToString(<RoutingContext {...renderProps} />))
31+
} else {
32+
res.send(404, 'Not found')
3333
}
3434
})
3535
})

0 commit comments

Comments
 (0)