mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
fix(nitro): handle ssr redirects (#392)
This commit is contained in:
parent
ef0190be02
commit
bbfa41f811
@ -1,3 +1,4 @@
|
|||||||
|
import type { ServerResponse } from 'http'
|
||||||
import { createRenderer } from 'vue-bundle-renderer'
|
import { createRenderer } from 'vue-bundle-renderer'
|
||||||
import devalue from '@nuxt/devalue'
|
import devalue from '@nuxt/devalue'
|
||||||
import { runtimeConfig } from './config'
|
import { runtimeConfig } from './config'
|
||||||
@ -47,7 +48,7 @@ function renderToString (ssrContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function renderMiddleware (req, res) {
|
export async function renderMiddleware (req, res: ServerResponse) {
|
||||||
let url = req.url
|
let url = req.url
|
||||||
|
|
||||||
// payload.json request detection
|
// payload.json request detection
|
||||||
@ -75,6 +76,10 @@ export async function renderMiddleware (req, res) {
|
|||||||
throw ssrContext.error
|
throw ssrContext.error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ssrContext.redirected || res.writableEnded) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (ssrContext.nuxt.hooks) {
|
if (ssrContext.nuxt.hooks) {
|
||||||
await ssrContext.nuxt.hooks.callHook('app:rendered')
|
await ssrContext.nuxt.hooks.callHook('app:rendered')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user