[stimulus-bundle] Fix broken CSRF header generation with Turbo forms (#1377)

This commit is contained in:
Alexander Hofbauer
2025-01-23 12:15:16 +01:00
committed by GitHub
parent 452e626976
commit 2d8f656159
@@ -9,7 +9,7 @@ document.addEventListener('submit', function (event) {
// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie
// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked
document.addEventListener('turbo:submit-start', function (event) {
const h = generateCsrfHeaders(event.detail.formSubmission);
const h = generateCsrfHeaders(event.detail.formSubmission.formElement);
Object.keys(h).map(function (k) {
event.detail.formSubmission.fetchRequest.headers[k] = h[k];
});