mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Increase default api request limit to 1mb
- expose it via settings.apiMaxLength - audit log api errors
This commit is contained in:
parent
9c3be40fbe
commit
7b6bc1d3bc
@ -28,13 +28,20 @@ var info = require("./info");
|
|||||||
var theme = require("./theme");
|
var theme = require("./theme");
|
||||||
var locales = require("./locales");
|
var locales = require("./locales");
|
||||||
|
|
||||||
|
var log = require("../log");
|
||||||
|
|
||||||
var auth = require("./auth");
|
var auth = require("./auth");
|
||||||
var needsPermission = auth.needsPermission;
|
var needsPermission = auth.needsPermission;
|
||||||
|
|
||||||
var settings = require("../settings");
|
var settings = require("../settings");
|
||||||
|
|
||||||
var errorHandler = function(err,req,res,next) {
|
var errorHandler = function(err,req,res,next) {
|
||||||
|
if (err.message === "request entity too large") {
|
||||||
|
log.error(err);
|
||||||
|
} else {
|
||||||
console.log(err.stack);
|
console.log(err.stack);
|
||||||
|
}
|
||||||
|
log.audit({event: "api.error",error:err.code||"unexpected_error",message:err.toString()},req);
|
||||||
res.status(400).json({error:"unexpected_error", message:err.toString()});
|
res.status(400).json({error:"unexpected_error", message:err.toString()});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,9 +61,9 @@ function init(adminApp,storage) {
|
|||||||
editorApp.use("/",ui.editorResources);
|
editorApp.use("/",ui.editorResources);
|
||||||
adminApp.use(editorApp);
|
adminApp.use(editorApp);
|
||||||
}
|
}
|
||||||
|
var maxApiRequestSize = settings.apiMaxLength || '1mb';
|
||||||
adminApp.use(bodyParser.json());
|
adminApp.use(bodyParser.json({limit:maxApiRequestSize}));
|
||||||
adminApp.use(bodyParser.urlencoded({extended:true}));
|
adminApp.use(bodyParser.urlencoded({limit:maxApiRequestSize,extended:true}));
|
||||||
|
|
||||||
adminApp.get("/auth/login",auth.login);
|
adminApp.get("/auth/login",auth.login);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user