Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prerender-server/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function doRender(req, res, next) {
return res.sendStatus(resp.errorCode)
}

res.status(resp.status || 200)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pass through 5xx errors to the client

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If resp.redirect exists, the server returns 301 via res.redirect(301, ...)
  • If resp.errorCode exists, the server returns that code via res.sendStatus(resp.errorCode)], for example 500, 504).
  • If err is thrown, it is passed to error handling next(err), typically resulting in 5xx.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    if (err) return next(err)
    if (resp.redirect) return res.redirect(301, baseHref + resp.redirect)
    if (resp.errorCode) {
      console.error(`Failed with code ${resp.errorCode}:`, resp)
      return res.sendStatus(resp.errorCode)
    }

res.status(200)
res.render(indexView, {
prerender_title: resp.title
, prerender_html: resp.html
Expand Down