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".
This commit is contained in:
Giuseppe Lombardo 2026-08-13 11:46:39 +00:00
parent 284a90222a
commit 8f4b985f79
2 changed files with 12 additions and 3 deletions

View File

@ -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);

View File

@ -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]);