mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
fix(nuxt): guard window
access more carefully
This commit is contained in:
parent
1dc51668a4
commit
977377777a
@ -7,6 +7,8 @@ import { defineNuxtPlugin } from '../nuxt'
|
||||
import { devLogs, devRootDir } from '#build/nuxt.config.mjs'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
if (!import.meta.client || import.meta.test) { return }
|
||||
|
||||
// Show things in console
|
||||
if (devLogs !== 'silent') {
|
||||
const logger = createConsola({
|
||||
@ -41,7 +43,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
|
||||
// pass SSR logs after hydration
|
||||
nuxtApp.hooks.hook('app:suspense:resolve', async () => {
|
||||
if (window && window.__NUXT_LOGS__) {
|
||||
if (typeof window !== 'undefined' && window.__NUXT_LOGS__) {
|
||||
await nuxtApp.hooks.callHook('dev:ssr-logs', window.__NUXT_LOGS__)
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user