解決 koa request entity too large


POST數據太大,出現了413錯誤,錯誤描述 request entity too large

原因:

使用了koa-body,koa-bodyparser,從它們的README看,接收的參數有默認大小

koa-body

- `jsonLimit` **{String|Integer}** The byte (if integer) limit of the JSON body, default `1mb`
- `formLimit` **{String|Integer}** The byte (if integer) limit of the form body, default `56kb`
- `textLimit` **{String|Integer}** The byte (if integer) limit of the text body, default `56kb`

koa-bodyparser

* **formLimit**: limit of the `urlencoded` body. If the body ends up being larger than this limit, a 413 error code is returned. Default is `56kb`.
* **jsonLimit**: limit of the `json` body. Default is `1mb`.
* **textLimit**: limit of the `text` body. Default is `1mb`.

解決的方法

const koaBody = require('koa-body');
const bodyParser = require('koa-bodyparser')

app.use(koaBody({
    multipart: true,
    formLimit:"10mb",
    jsonLimit:"10mb"
}));
app.use(bodyParser({
    formLimit:"10mb",
    jsonLimit:"10mb"
}));

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM