Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9773777

Browse files
committed
fix(nuxt): guard window access more carefully
1 parent 1dc5166 commit 9773777

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/nuxt/src/app/plugins/dev-server-logs.client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { defineNuxtPlugin } from '../nuxt'
77
import { devLogs, devRootDir } from '#build/nuxt.config.mjs'
88

99
export default defineNuxtPlugin((nuxtApp) => {
10+
if (!import.meta.client || import.meta.test) { return }
11+
1012
// Show things in console
1113
if (devLogs !== 'silent') {
1214
const logger = createConsola({
@@ -41,7 +43,7 @@ export default defineNuxtPlugin((nuxtApp) => {
4143

4244
// pass SSR logs after hydration
4345
nuxtApp.hooks.hook('app:suspense:resolve', async () => {
44-
if (window && window.__NUXT_LOGS__) {
46+
if (typeof window !== 'undefined' && window.__NUXT_LOGS__) {
4547
await nuxtApp.hooks.callHook('dev:ssr-logs', window.__NUXT_LOGS__)
4648
}
4749
})

0 commit comments

Comments
 (0)