Skip to content

Commit

Permalink
fix(nuxt): guard window access more carefully
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 16, 2024
1 parent 1dc5166 commit 9773777
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/nuxt/src/app/plugins/dev-server-logs.client.ts
Expand Up @@ -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({
Expand Down Expand Up @@ -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__)
}
})
Expand Down

0 comments on commit 9773777

Please sign in to comment.