mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
refactor: persist isModernBrowser on http connection (#4268)
This commit is contained in:
parent
f10f860292
commit
7d34f2ef26
@ -224,16 +224,18 @@ export default class VueRenderer {
|
||||
return { html, getPreloadFiles }
|
||||
}
|
||||
|
||||
const { req } = context
|
||||
const ua = req && req.headers && req.headers['user-agent']
|
||||
const isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
|
||||
const { req: { socket = {}, headers } = {} } = context
|
||||
if (socket.isModernBrowser === undefined) {
|
||||
const ua = headers && headers['user-agent']
|
||||
socket.isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
|
||||
allowHigherVersions: true,
|
||||
browsers: this.modernBrowsers
|
||||
})
|
||||
}
|
||||
|
||||
let APP
|
||||
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
|
||||
if (isModernBrowser) {
|
||||
if (socket.isModernBrowser) {
|
||||
APP = await this.renderer.modern.renderToString(context)
|
||||
} else {
|
||||
APP = await this.renderer.ssr.renderToString(context)
|
||||
|
Loading…
Reference in New Issue
Block a user