New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to proxy pdfkit response? #855

lexor90 opened this Issue Jul 13, 2015 · 0 comments


None yet
1 participant

lexor90 commented Jul 13, 2015

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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment