0

I have a problem with node.js html-pdf, its give me the error SET HEADER ERROR,

when I upload a file to any host like Amazon EC2 its give me Error: Can't set headers after they are sent to the client, but it works very will on my device host http://localhost:3000

that makes me confused about how to solve this problem

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());
      }
  });   
});

0 Answers0