From 579a0ddb75d676fa708e6d4194006faaaadaaa88 Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Mon, 3 Aug 2026 18:22:27 +0200 Subject: [PATCH] fix of the json upload format --- Web/templates/upload_batch.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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();