mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 11:57:13 +00:00
refacotr: replace ctx.error with _redirected
This commit is contained in:
parent
8868276e37
commit
37c256ade2
@ -7,6 +7,9 @@ export default {
|
||||
name: 'nuxt',
|
||||
props: ['nuxtChildKey'],
|
||||
render(h) {
|
||||
if (this.nuxt._redirected) {
|
||||
return h('div', [ 'redirecting.' ])
|
||||
}
|
||||
// If there is some error
|
||||
if (this.nuxt.err) {
|
||||
return h('nuxt-error', {
|
||||
|
@ -148,7 +148,8 @@ export async function setContext(app, context) {
|
||||
}
|
||||
if (process.server) {
|
||||
app.context.res.setHeader('Location', path)
|
||||
app.context.error({ statusCode: status, message: 'Redirecting to ' + path })
|
||||
app.context.res.statusCode = status
|
||||
app.nuxt._redirected = true
|
||||
}
|
||||
if (process.client) {
|
||||
window.location = path
|
||||
|
@ -121,7 +121,7 @@ test('/redirect -> external link', async t => {
|
||||
}
|
||||
})
|
||||
t.is(headers.Location, 'https://nuxtjs.org/')
|
||||
t.true(html.includes('Redirecting to https://nuxtjs.org/'))
|
||||
t.true(html.includes('<div>redirecting.</div>'))
|
||||
})
|
||||
|
||||
test('/special-state -> check window.__NUXT__.test = true', async t => {
|
||||
|
Loading…
Reference in New Issue
Block a user