0

I'm trying to figure out how to proxy a request of a pdf file generated at runtime with pdfkit.

Response headers of the backend service are set to

res.setHeader('Content-type', 'application/pdf');
// only if req.params.view != undefined
res.setHeader('Content-disposition', 'attachment; filename=' + req.params.template + '_' + id + '.pdf');

This allows to view the pdf inside browser (by just sending out the first header) or download it by also sending the second header.

While pdfkit generates the file it is piped to the response. If I try it by contacting the backend directly it works, while using the proxy it's raising a ECONNRESET error.

I guess it might depend on the client terminating the request before to receive the chunked response, how can I allow the backend service to pipe the request as the backend is processing the pdf?

I'm surely missing something... thank you!!

Viciè
  • 3
  • 4

0 Answers0