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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user