diff --git a/app/templates/bank_import/index.html b/app/templates/bank_import/index.html
index e7cc854..1b4d687 100644
--- a/app/templates/bank_import/index.html
+++ b/app/templates/bank_import/index.html
@@ -314,8 +314,17 @@
fd.append('file', selectedFile);
if (colMap) fd.append('col_map', JSON.stringify(colMap));
- fetch('{{ url_for("bank_import.parse") }}', { method: 'POST', body: fd })
- .then(r => r.json())
+ fetch('{{ url_for("bank_import.parse") }}', {
+ method: 'POST',
+ headers: { 'X-CSRFToken': CSRF },
+ body: fd,
+ })
+ .then(r => {
+ if (!r.ok && !r.headers.get('content-type')?.includes('application/json')) {
+ throw new Error(`Server error ${r.status} — check server logs for details.`);
+ }
+ return r.json();
+ })
.then(data => {
setParseLoading(false);
if (data.error) {