Actually make multiplart also optional

This commit is contained in:
Johannes Zellner
2026-01-28 14:01:22 +01:00
parent a66c3700b3
commit aa84cb0079
4 changed files with 17 additions and 8 deletions
+5 -2
View File
@@ -45,9 +45,12 @@ async function initializeExpressSync() {
const QUERY_LIMIT = '2mb', // max size for json queries (see also client_max_body_size in nginx)
FIELD_LIMIT = 2 * 1024 * 1024; // max fields that can appear in multipart
const multipart = middleware.multipart({ maxFieldsSize: FIELD_LIMIT, limit: FILE_SIZE_LIMIT, timeout: FILE_TIMEOUT });
const multipart = middleware.multipart({ maxFieldsSize: FIELD_LIMIT, limit: FILE_SIZE_LIMIT, timeout: FILE_TIMEOUT }, true); // forces multipart content-type
const json = middleware.json({ strict: true, limit: QUERY_LIMIT }, true); // forces json content-type
const jsonOrMultipart = [ middleware.json({ strict: true, limit: QUERY_LIMIT }, false), multipart ];
const jsonOrMultipart = [
middleware.json({ strict: true, limit: QUERY_LIMIT }, false),
middleware.multipart({ maxFieldsSize: FIELD_LIMIT, limit: FILE_SIZE_LIMIT, timeout: FILE_TIMEOUT }, false)
];
app.set('json spaces', 2); // pretty json
app.enable('trust proxy'); // trust the X-Forwarded-* headers