From 8f4b985f7935626e3a4f2d842fd096365f82abd9 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 13 Aug 2026 11:46:39 +0000 Subject: [PATCH] Fix HTTP 413 when accepting a tenant invite with ID/Schufa uploads Accepting an invitation as TENANT now sends up to three files (ID front, ID back, optional Schufa) as base64 data URLs in one JSON body. Raises express.json's limit from 10mb to 30mb so three real phone photos fit. Also adds a client-side 8MB-per-file check with a clear error message instead of letting an oversized file hit the server limit and surface a bare "Status 413". --- backend/src/app.ts | 9 ++++++--- web-dashboard/index.html | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index 7c37e23..3eb972a 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -34,9 +34,12 @@ export function createApp() { app.use(cors({ origin: true })); // Alle übrigen Routen bekommen normal geparstes JSON. Limit angehoben, da - // die Inventarverwaltung mehrere Fotos als Data-URLs im Body versendet - // (keine separate Objekt-Storage-Anbindung in diesem Demo-Stand). - app.use(express.json({ limit: '10mb' })); + // Inventarfotos, Vertragsdokumente und beim Einladung-Annehmen bis zu drei + // Dateien (Ausweis vorne/hinten, optional Schufa) als Data-URLs im Body + // versendet werden (keine separate Objekt-Storage-Anbindung in diesem + // Demo-Stand). 10mb reichte für einzelne Fotos, war aber zu knapp für drei + // hochauflösende Handyfotos in einem Request (HTTP 413). + app.use(express.json({ limit: '30mb' })); app.use('/v1', paymentsRouter); app.use('/v1', cockpitRouter); app.use('/v1', authRouter); diff --git a/web-dashboard/index.html b/web-dashboard/index.html index e04bba8..0935878 100644 --- a/web-dashboard/index.html +++ b/web-dashboard/index.html @@ -1209,6 +1209,12 @@ const password = document.getElementById('acceptPassword').value; const body = { fullName, password }; if (isTenant) { + const MAX_UPLOAD_BYTES = 8 * 1024 * 1024; // 8MB je Datei, reichlich Luft unter dem 30mb-Server-Limit für alle 3 Dateien zusammen + const tooLarge = [idFrontInput.files[0], idBackInput.files[0], schufaInput.files[0]] + .filter(f => f && f.size > MAX_UPLOAD_BYTES); + if (tooLarge.length) { + throw new Error(`Datei zu groß (max. 8 MB): ${tooLarge.map(f => f.name).join(', ')}. Bitte kleineres Foto/Scan wählen.`); + } body.phoneNumber = document.getElementById('acceptPhone').value.trim(); body.firstResidenceAddress = document.getElementById('acceptFirstResidence').value.trim(); body.idDocumentFrontUrl = await readFileAsDataUrl(idFrontInput.files[0]);