Fix redirected

This commit is contained in:
Sébastien Chopin 2017-02-22 18:19:17 +00:00
parent 749673c99b
commit 66c5aad09d
2 changed files with 4 additions and 2 deletions

View File

@ -25,9 +25,9 @@ export default context => {
// create context.next for simulate next() of beforeEach() when wanted to redirect // create context.next for simulate next() of beforeEach() when wanted to redirect
context.redirected = false context.redirected = false
context.next = function (opts) { context.next = function (opts) {
context.redirected = opts
// if nuxt generate // if nuxt generate
if (!context.res) { if (!context.res) {
context.redirected = opts
context.nuxt.serverRendered = false context.nuxt.serverRendered = false
return return
} }

View File

@ -59,7 +59,9 @@ export function render (req, res) {
return this.renderRoute(req.url, context) return this.renderRoute(req.url, context)
}) })
.then(({ html, error, redirected }) => { .then(({ html, error, redirected }) => {
if (redirected) return html if (redirected) {
return html
}
if (error) { if (error) {
res.statusCode = context.nuxt.error.statusCode || 500 res.statusCode = context.nuxt.error.statusCode || 500
} }