小编Tho*_*s G的帖子

负载内容长度大于允许的最大值:1048576 - Axios (Electron) 和 nodeJS

我正在从我的 Electron 应用程序请求我的节点 API 服务器,但出现此错误:

body: '{"statusCode":400,"error":"Bad Request","message":"Payload content length greater than maximum allowed: 1048576"}'
Run Code Online (Sandbox Code Playgroud)

我发送 Base 64 编码的图像。使用来自我的 Angular 网站的 Http 客户端,请求运行良好,但使用 Axios (Electron),它不起作用。

 updateUser: function(user, callback) {
      axios.post(environnement.urlServer+'update-user', {
        user: user
      })
      .then((response) => {
        callback(response.data);
      }, (error) => {
        console.log(error);
      });
    }
Run Code Online (Sandbox Code Playgroud)

我的节点服务器限制增加:

app.use(bodyParser.json({limit: "100mb", extended: true}))
app.use(bodyParser.urlencoded({limit: "100mb", extended: true}))

Run Code Online (Sandbox Code Playgroud)

我尝试了很多东西,但没有找到解决方案。

javascript node.js express electron

5
推荐指数
0
解决办法
1124
查看次数

标签 统计

electron ×1

express ×1

javascript ×1

node.js ×1