mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
perf(vue-renderer): early return render
when redirect happens (#6973)
This commit is contained in:
parent
b71eaee879
commit
bfad1e627b
@ -83,6 +83,14 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
APP = `<div id="${this.serverContext.globals.id}"></div>`
|
APP = `<div id="${this.serverContext.globals.id}"></div>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renderContext.redirected && !renderContext._generate) {
|
||||||
|
return {
|
||||||
|
html: APP,
|
||||||
|
error: renderContext.nuxt.error,
|
||||||
|
redirected: renderContext.redirected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let HEAD = ''
|
let HEAD = ''
|
||||||
|
|
||||||
// Inject head meta
|
// Inject head meta
|
||||||
|
@ -155,6 +155,7 @@ describe('basic ssr', () => {
|
|||||||
test('/redirect', async () => {
|
test('/redirect', async () => {
|
||||||
const { html, redirected } = await nuxt.server.renderRoute('/redirect')
|
const { html, redirected } = await nuxt.server.renderRoute('/redirect')
|
||||||
expect(html).toContain('<div id="__nuxt"></div>')
|
expect(html).toContain('<div id="__nuxt"></div>')
|
||||||
|
expect(html).not.toContain('window.__NUXT__')
|
||||||
expect(redirected.path === '/').toBe(true)
|
expect(redirected.path === '/').toBe(true)
|
||||||
expect(redirected.status === 302).toBe(true)
|
expect(redirected.status === 302).toBe(true)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user