File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,20 @@ link.href = `${overlayDir}/devtools-overlay.css`
4141
4242// create script
4343const script = document . createElement ( 'script' )
44- script . src = `${ overlayDir } /devtools-overlay.mjs`
44+ const scriptUrl = `${ overlayDir } /devtools-overlay.mjs`
45+ // Under a `require-trusted-types-for 'script'` CSP, assigning a string to
46+ // `script.src` is blocked. Wrap the URL in a TrustedScriptURL via a named
47+ // policy so apps can opt-in by allowing `vue-devtools` in their CSP's
48+ // `trusted-types` directive.
49+ if ( typeof window !== 'undefined' && window . trustedTypes && typeof window . trustedTypes . createPolicy === 'function' ) {
50+ const policy = window . trustedTypes . createPolicy ( 'vue-devtools' , {
51+ createScriptURL : input => input ,
52+ } )
53+ script . src = policy . createScriptURL ( scriptUrl )
54+ }
55+ else {
56+ script . src = scriptUrl
57+ }
4558script . type = 'module'
4659
4760// append to head
You can’t perform that action at this time.
0 commit comments