Hi,
This part of dmxRouting.js cause that <script>
tags that containg CSP nonce
trigger errors.
Im using nonce dynamically created in nodejs in a helmet middleware file.
evalScripts: function(t) {
try {
var e = t.querySelectorAll('script[type="text/javascript"],script:not([type])');
dmx.array(e).forEach(function(e) {
try {
var t = document.createElement("script");
t.type = "text/javascript",
e.src && (t.src = e.src),
e.innerHTML && (t.innerHTML = e.innerHTML),
e.onerror = function() {
console.error("ERROR", arguments)
}
,
e.parentNode.replaceChild(t, e)
} catch (t) {
console.error("Error executing script " + e.src, t)
}
})
} catch (t) {
console.error("An error occurred while trying to execute scripts", t)
}
},
In another part of the same file where you use document.createElement("script")
it also throws the same error.
Its possible to add this to retrieve the nonce in the new script that the createElement creates.
var t = document.createElement("script");
t.type = "text/javascript",
e.src && (t.src = e.src),
e.innerHTML && (t.innerHTML = e.innerHTML),
// Get the nonce from the existing script tag and add it to the new one
e.nonce && (t.nonce = e.nonce),
About CSP here:
https://content-security-policy.com/nonce/
Thanks