zoukankan      html  css  js  c++  java
  • 解决 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"
    }));
  • 相关阅读:
    C# 检测dll的新版本号方法
    DataGridView 单击赋值
    一致性Hash算法
    .net Parallel并行使用注意事项
    析构函数和Dispose方法的区别
    查看SQLServer的最大连接数
    Hash算法-CityHash算法
    Hash算法
    Sunday算法--C#版
    KMP算法--C#版
  • 原文地址:https://www.cnblogs.com/baby123/p/13359472.html
Copyright © 2011-2022 走看看