Node.js Meteor:Iron路由器错误请求实体太大

Node.js Meteor:Iron路由器错误请求实体太大,node.js,express,meteor,websocket,iron-router,Node.js,Express,Meteor,Websocket,Iron Router,我正在尝试将数据从NodeJS服务器发送到meteor应用程序。在node js应用程序中,我正在执行以下操作: axios.put('http://localhost:3000/api/project/'+id,{"data" :data, "idExtractor":idExtractor, "version":getVersion()}) 其中,数据是服务器提供的XML字符串 在我的meteor应用程序中,我通过lib/Router.js文件中的服务器路由接收到这个消息,但是当数据太大时

我正在尝试将数据从NodeJS服务器发送到meteor应用程序。在node js应用程序中,我正在执行以下操作:

axios.put('http://localhost:3000/api/project/'+id,{"data" :data, "idExtractor":idExtractor, "version":getVersion()})
其中,数据是服务器提供的XML字符串

在我的meteor应用程序中,我通过lib/Router.js文件中的服务器路由接收到这个消息,但是当数据太大时,meteor服务器会给我错误“套接字挂起”和“请求实体太大”

我尝试了github上Iron Router问题的解决方案,在Router.js文件中执行以下代码

if (Meteor.isServer) {
  Router.onBeforeAction(Iron.Router.bodyParser.raw({ 
    type: '/', 
    only: ['creditReferral'], 
    verify: function(req, res, body){
      req.rawBody = body.toString(); 
    },
    where: 'server'
  }));
  Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
    extended: true,
    limit : '10mb'
  }));
  Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
    extended: true,
    limit : '10mb' 
  }), 
  { where: 'server'});
}
我试着把它放在所有路由定义之前,服务器路由之前,所有路由之后,我还试着把它放在启动块的server/main.js中

我还尝试使用此命令更改节点服务器中的这些限制

express.urlencoded({
  limit: '10mb', 
  extended: true, 
  type: "application/x-www-form-urlencoded"
})
express.json({
  limit: '10mb', 
  strict: false, 
  type: "application/json"
})
还有这个

app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit :'10mb' }));

但是我总是遇到同样的问题,非常感谢所有的帮助。

在尝试了许多解决方案后,我在我的Router.js中修复了这个问题:

if (Meteor.isServer) {
    Router.onBeforeAction( Iron.Router.bodyParser.json({
        limit: '50mb'
    }), {
        except: ['creditReferral'],
        where: 'server'
    });
    Router.onBeforeAction( Iron.Router.bodyParser.raw({
        type: '*/*',
        only: ['creditReferral'],
        verify: function(req, res, body){
            req.rawBody = body.toString();
        },
        where: 'server'}));
}
这修复了实体太大的错误,但由于此请求中的数据是xml,我无法直接将其解析为json,因此我需要更改

var json = JSON.parse(this.request.body) 
对下列事项:

var stringify = JSON.stringify(this.request.body);
var json = JSON.parse(stringify);
它成功了。希望这能帮助有同样问题的人