mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +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 }
|
return { html, getPreloadFiles }
|
||||||
}
|
}
|
||||||
|
|
||||||
const { req } = context
|
const { req: { socket = {}, headers } = {} } = context
|
||||||
const ua = req && req.headers && req.headers['user-agent']
|
if (socket.isModernBrowser === undefined) {
|
||||||
const isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
|
const ua = headers && headers['user-agent']
|
||||||
|
socket.isModernBrowser = this.renderer.modern && ua && matchesUA(ua, {
|
||||||
allowHigherVersions: true,
|
allowHigherVersions: true,
|
||||||
browsers: this.modernBrowsers
|
browsers: this.modernBrowsers
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
let APP
|
let APP
|
||||||
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
|
// 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)
|
APP = await this.renderer.modern.renderToString(context)
|
||||||
} else {
|
} else {
|
||||||
APP = await this.renderer.ssr.renderToString(context)
|
APP = await this.renderer.ssr.renderToString(context)
|
||||||
|
Loading…
Reference in New Issue
Block a user