diff --git a/Web/templates/upload_batch.html b/Web/templates/upload_batch.html index d38cf06..4db8874 100644 --- a/Web/templates/upload_batch.html +++ b/Web/templates/upload_batch.html @@ -165,12 +165,22 @@ const formData = new FormData(form); + const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content'); + + const fetchOptions = { + method: 'POST', + body: formData, + credentials: 'include' + }; + + if (csrfToken) { + fetchOptions.headers = { + 'X-CSRFToken': csrfToken + }; + } + try { - const response = await fetch('/upload_csv_batch', { - method: 'POST', - body: formData, - credentials: 'include' - }); + const response = await fetch('/upload_csv_batch', fetchOptions); // Antwort einmalig als Text auslesen, um sowohl JSON als auch HTML-Fehler abzufangen const responseText = await response.text();