Skip to content

Commit ff62273

Browse files
committed
fix: disable devtools when frame app is embedded
1 parent dc9b6fc commit ff62273

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/module.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ const _module: NuxtModule<NuxtStoriesOptions> = defineNuxtModule<NuxtStoriesOpti
7777
// • alias → tells Vite where to find the package (resolves bare + subpath imports)
7878
// • build.transpile → prevents Vite AND Nitro from externalising them; Nuxt propagates
7979
// transpile entries to nitro.externals.inline automatically
80+
// In frame mode, suppress the devtools overlay when running inside the shell's iframe.
81+
// Must be an inline <head> script — Nuxt plugins run too late and devtools initialises
82+
// before them, causing a cross-origin error when it tries to read window.parent.__NUXT_DEVTOOLS_DISABLE__.
83+
// When the frame URL is opened directly window.self === window.top so the flag is never set.
84+
if (mode === 'frame') {
85+
nuxt.options.app.head.script ||= []
86+
nuxt.options.app.head.script.unshift({
87+
innerHTML: `if(window.self!==window.top)window.__NUXT_DEVTOOLS_DISABLE__=true`,
88+
tagPosition: 'head',
89+
})
90+
}
91+
8092
if (mode !== 'frame') {
8193
// PrimeVue is registered via a client-only plugin to avoid any server-side
8294
// imports (which would break Nitro dev resolution via Node.js native ESM).

0 commit comments

Comments
 (0)