Skip to content

Commit

Permalink
fix(nitro): handle ssr redirects (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jul 27, 2021
1 parent 05d6d57 commit 42405c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/app/render.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ServerResponse } from 'http'
import { createRenderer } from 'vue-bundle-renderer'
import devalue from '@nuxt/devalue'
import { runtimeConfig } from './config'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
}
Expand Down

0 comments on commit 42405c2

Please sign in to comment.