記一次node項目報錯(PayloadTooLargeError: too many parameters)

報錯內容:

2|travel-n | 2020-06-01 18:31 +08:00: PayloadTooLargeError: too many parameters
2|travel-n | 2020-06-01 18:31 +08:00:     at queryparse (/www/wwwroot/product/travel-network-web/node_modules/body-parser/lib/types/urlencoded.js:151:13)
2|travel-n | 2020-06-01 18:31 +08:00:     at parse (/www/wwwroot/product/travel-network-web/node_modules/body-parser/lib/types/urlencoded.js:75:9)
2|travel-n | 2020-06-01 18:31 +08:00:     at /www/wwwroot/product/travel-network-web/node_modules/body-parser/lib/read.js:121:18
2|travel-n | 2020-06-01 18:31 +08:00:     at invokeCallback (/www/wwwroot/product/travel-network-web/node_modules/raw-body/index.js:224:16)
2|travel-n | 2020-06-01 18:31 +08:00:     at done (/www/wwwroot/product/travel-network-web/node_modules/raw-body/index.js:213:7)
2|travel-n | 2020-06-01 18:31 +08:00:     at IncomingMessage.onEnd (/www/wwwroot/product/travel-network-web/node_modules/raw-body/index.js:273:7)
2|travel-n | 2020-06-01 18:31 +08:00:     at IncomingMessage.emit (events.js:203:15)
2|travel-n | 2020-06-01 18:31 +08:00:     at endReadableNT (_stream_readable.js:1145:12)
2|travel-n | 2020-06-01 18:31 +08:00:     at process._tickCallback (internal/process/next_tick.js:63:19)
2|travel-n | 2020-06-01 18:33 +08:00: product product
2|travel-n | 2020-06-01 18:33 +08:00: Mon, 01 Jun 2020 10:33:11 GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:242:13

解決方案:app.js中添加以下代碼

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));

parameterLimit選項控制URL編碼數據中允許的最大參數數量。如果請求中包含的參數比該值更多,則將413返回給客戶端。預設爲1000

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章