今天在做上传图的功能时遇到报错413 Payload Too Large;
express deprecated res.send(status): Use res.sendStatus(status) instead index.js:18:13
PayloadTooLargeError: request entity too large
at readStream (C:\Users\Administrator\node_modules\raw-body\index.js:156:17)
at getRawBody (C:\Users\Administrator\node_modules\raw-body\index.js:109:12)
at read (C:\Users\Administrator\node_modules\body-parser\lib\read.js:79:3)
at jsonParser (C:\Users\Administrator\node_modules\body-parser\lib\types\json.js:135:5)
at Layer.handle [as handle_request] (C:\Users\Administrator\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\Administrator\node_modules\express\lib\router\index.js:328:13)
at C:\Users\Administrator\node_modules\express\lib\router\index.js:286:9
at Function.process_params (C:\Users\Administrator\node_modules\express\lib\router\index.js:346:12)
at next (C:\Users\Administrator\node_modules\express\lib\router\index.js:280:10)
at expressInit (C:\Users\Administrator\node_modules\express\lib\middleware\init.js:40:5)
问题原因: nodejs 做为服务器,在传输内容或者上传文件时,系统默认大小为100kb; 解决方法:
const bodyParser = require('body-parser') //引入第三方中间件,要在router之前引入才能通过req.body获取到请求的数据 app.use(bodyParser.json({limit: '5000mb'})); app.use(bodyParser.urlencoded({limit: '5000mb',extended:false}))
标签:node,Administrator,Users,nodejs,express,modules,js,报错 From: https://www.cnblogs.com/SadicZhou/p/16949943.html