0

我有 node.js html-pdf 的问题,它给了我错误 SET HEADER ERROR,

当我将文件上传到像 Amazon EC2 这样的任何主机时,它会给我Error: Can't set headers after they are sent to the client,但它在我的设备主机上非常有效http://localhost:3000

这让我对如何解决这个问题感到困惑

const pdfTemplate = require('./documents');
var options = { orientation: "landscape",format: "A4", };

app.post('/create-pdf', (req, res) => {
  let fullUrl = req.protocol + '://' + req.get('host');

  pdf.create(pdfTemplate(req.body, fullUrl), options).toFile('result.pdf', (err) => {
      if(err) {
          res.send(Promise.reject());
      } 
      else {
        res.send(Promise.resolve());
      }
  });   
});
4

0 回答 0