node.js - 错误: Request body larger than maxBodyLength limit when sending base64 post request Axios

标签 node.js axios

当发送以 Base64 编码的 pdf 作为正文的发布请求时,我收到错误

错误:请求正文大于 maxBodyLength 限制

我已尝试设置以下两项

'maxContentLength':无穷大, 'maxBodyLength':无穷大

在请求配置中

const result = await axios({
            url: `the url`,
            headers: {'Authorization': `Bearer ${auth_token}`, 'Content-Type': 'application/json'},
            method: 'post',
            data: {
                'ParentId': record_id,
                'Name': file_name,
                'body': body,
                'Description': description ? description : "",
                'maxContentLength': Infinity,
                'maxBodyLength': Infinity
            }
        });

有人有解决办法吗?

最佳答案

您正在设置

'maxContentLength': Infinity,
'maxBodyLength': Infinity

在您的数据对象中。它应该位于配置对象内部,外部数据对象。

关于node.js - 错误: Request body larger than maxBodyLength limit when sending base64 post request Axios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56868023/

相关文章:

javascript - 为什么 console.log() 在异步代码上有效,但 array.push() 无效?

javascript - 获取 GET 请求的正文(NodeJS + axios)

javascript - 带有空格的 Axios GET 请求参数

reactjs - 如何使用 axios 上传图像数组?

Axios:在请求中将空值作为参数发送

node.js - Grunt + Node 应用程序 + livereload

linux - 通过 NPM 在 Debian Lenny (5.0) 中安装 Forever - 错误

Node.js 无法识别新模块

node.js - 如何从 express.static 检测 404 错误

node.js - 安装 MobileFirst Platform mfpdev-cli 时出现 Node 错误