Skip to content

Commit 0eb7a82

Browse files
committed
fix: support iframeProps option for CSP, fix Stackblitz
1 parent 988850f commit 0eb7a82

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/devtools-kit/src/_types/options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export interface ModuleOptions {
4747
*/
4848
disableAuthorization?: boolean
4949

50+
/**
51+
* Props for the iframe element, useful for environment with stricter CSP
52+
*/
53+
iframeProps?: Record<string, string | boolean>
54+
5055
/**
5156
* Experimental features
5257
*/

packages/devtools/src/module-main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export async function enableModule(options: ModuleOptions, nuxt: Nuxt) {
4040

4141
await nuxt.callHook('devtools:before')
4242

43+
if (options.iframeProps)
44+
nuxt.options.runtimeConfig.app.iframeProps = options.iframeProps
45+
4346
// Make unimport exposing more information, like the usage of each auto imported function
4447
nuxt.options.imports.collectMeta = true
4548

packages/devtools/src/runtime/plugins/view/client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,13 @@ export async function setupDevToolsClient({
128128
const initialUrl = CLIENT_PATH + state.value.route
129129
try {
130130
iframe = document.createElement('iframe')
131+
132+
// custom iframe props
133+
Object.fromEntries(runtimeConfig.app.devtools?.iframeProps || {})
134+
for (const [key, value] of Object.entries(runtimeConfig.app.devtools?.iframeProps || {}))
135+
iframe.setAttribute(key, String(value))
136+
131137
iframe.id = 'nuxt-devtools-iframe'
132-
iframe.allow = 'cross-origin-isolated'
133-
iframe.setAttribute('credentialless', 'true')
134138
iframe.src = initialUrl
135139
iframe.onload = async () => {
136140
try {

0 commit comments

Comments
 (0)