feat(server): add raw body parsing for multipart/form-data and application/octet-stream

- Implemented a new middleware to handle raw body parsing for specific content types, allowing for larger payloads up to 5mb.
- Enhanced form body serialization to support Buffer input, improving compatibility with various data formats during proxy interactions.
This commit is contained in:
Torsten Schulz (local)
2026-03-11 12:45:25 +01:00
parent e5e1ccba82
commit c1f45b2b98
2 changed files with 9 additions and 0 deletions

View File

@@ -45,6 +45,10 @@ function serializeFormBody(req) {
return req.rawBody;
}
if (Buffer.isBuffer(req.body) && req.body.length > 0) {
return req.body.toString('utf8');
}
if (typeof req.body === 'string') {
return req.body;
}

View File

@@ -75,6 +75,11 @@ app.use(cors({
allowedHeaders: ['Content-Type', 'Authorization', 'authcode', 'userid']
}));
app.use('/api/clicktt/proxy', express.raw({
type: ['multipart/form-data', 'application/octet-stream'],
limit: '5mb',
verify: captureRawBody,
}));
app.use(express.json({ verify: captureRawBody }));
app.use(express.urlencoded({ extended: true, verify: captureRawBody }));