简体   繁体   English

增加REST-API中节点+ Express的时间

[英]Increase time in REST-API, node + express

I'm generating a huge .docx document in a rest-api call. 我在rest-api调用中生成了一个巨大的.docx文档。 It takes several minutes for it to complete. 它需要几分钟才能完成。 Problem is the server somehow sends a "timeout" after a minute or so. 问题是服务器在大约一分钟后以某种方式发送“超时”。 Is there anyway to increase this time? 无论如何有增加这个时间? Is it a browser thing or can I change it in express? 它是浏览器内容还是我可以直接更改它?

exports.generateDoc = function(req, res){
  var file = generateDoc(); //This takes several minutes
  res.setHeader('Content-disposition', 'attachment; filename=output.docx');
  res.end(file,'binary');
}

You can set the timeout of an HTTP server in Node using the server.setTimeout() method which is described in the Node docs here . 您可以使用server.setTimeout()方法在Node中设置HTTP服务器的超时,该方法在Node文档中进行了介绍

There's also the Express middlewhere timeout which may help with Express. 还有Express Middlewhere 超时可能对Express有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM