piston icon indicating copy to clipboard operation
piston copied to clipboard

Express API server not respecting PISTON_MAX_FILE_SIZE

Open funsim opened this issue 10 months ago • 0 comments

The Express API uses the default body_parser settings, which results in a 100kb body size limit. To fix, this, we would need to read the PISTON_MAX_FILE_SIZE value and use it like the example below:

--- index.js	2025-03-18 14:10:16
+++ index.js	2025-03-18 14:10:14
@@ -64,8 +64,8 @@
     logger.debug('Constructing Express App');
     logger.debug('Registering middleware');

-    app.use(body_parser.urlencoded({ extended: true }));
-    app.use(body_parser.json());
+    app.use(body_parser.urlencoded({ extended: true, limit: '10mb' }));
+    app.use(body_parser.json({ limit: '10mb' }));

     app.use((err, req, res, next) => {
         return res.status(400).send({

funsim avatar Mar 18 '25 13:03 funsim