mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +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 devalue from '@nuxt/devalue'
|
||||
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
|
||||
|
||||
// payload.json request detection
|
||||
@ -75,6 +76,10 @@ export async function renderMiddleware (req, res) {
|
||||
throw ssrContext.error
|
||||
}
|
||||
|
||||
if (ssrContext.redirected || res.writableEnded) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ssrContext.nuxt.hooks) {
|
||||
await ssrContext.nuxt.hooks.callHook('app:rendered')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user