scinote-web/app/assets/javascripts/shared/turbo_link_csp.js
Soufiane b40c750965
Turbolinks broken by default with a secure CSP [SCI-8583] (#5529)
* Fix broken Turbolinks with CSP nonce [SCI-8583]
2023-05-31 15:28:16 +02:00

10 lines
371 B
JavaScript

document.addEventListener('turbolinks:request-start', function(event) {
var xhr = event.data.xhr;
xhr.setRequestHeader('X-Turbolinks-Nonce', $('meta[name="csp-nonce"]').prop('content'));
});
document.addEventListener('turbolinks:before-cache', function() {
$('script[nonce]').each(function(_index, element) {
$(element).attr('nonce', element.nonce);
});
});