javascript - Ajax POST 413 负载太大 NodeJs + Express 4>
问题描述
我的 Ajax POST 抛出错误 413 Payload Too Large。我在我的 nodejs 代码中尝试了以下解决方案:
"use strict";
var bodyParser = require('body-parser');
var express = require('express');
var jsonParser = bodyParser.json();
var workspace = (app, dbconn)=>{
app.use( bodyParser.json({limit: '50mb'}) );
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true,
parameterLimit:50000
}));
}
但这仍然抛出错误。
我的ajax调用如下:
$.ajax({
url: "/private/save_ws",
type: 'post',
headers: {'x-secure':_user_token, 'x-user':_user_name},
contentType: 'application/json',
dataType: 'json',
data: widget_data
}).done(function(response){
console.log('success');
}).fail(function(data){
console.log('FAILED! ERROR: ');
});
解决方案
推荐阅读
- html - HTML2PDF 图像标签中断转换,没有错误
- r - 我正在 R 中进行集成,并定义了一个函数 N,如下所示:
- microservices - 如何使用 pubsub 配置 seluth 跟踪
- javascript - 通过 json 解析并在 gadget.io.makeRequest 上获取特定元素
- python - 如何在另一个函数上使用错误处理函数?
- python - 没有名为“psutil”的模块
- c# - Datagrid 填充 MySQL 数据操作数据
- binary - 如何计算给定 n 位的多余 N 的范围?
- loops - Rust:迭代 iter() 或向量本身
- vue.js - Webpack 在 head 标签而不是 body 标签中注入 bundle