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 }
|
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)
|
||||||
|
@ -23,7 +23,7 @@ const _require = esm(module, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
module.exports = _require('../src/index')
|
module.exports = _require('../src/index')
|
||||||
`}
|
` }
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// Read package at current directory
|
// Read package at current directory
|
||||||
|
Loading…
Reference in New Issue
Block a user