alvarcarto / url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
MIT License
7.01k stars 774 forks source link

Added ability to setExtraHTTPHeaders #78

Closed maxshuty closed 5 years ago

maxshuty commented 6 years ago

I have added the ability to send custom headers which will help a lot of folks to resolve issues passing along a token for auth or whatever other use case they may have.

An example usage of how this is to be used is:

    "setExtraHTTPHeaders": {
        "customHeader": "test"
    }

I'm a .NET developer by nature, but I needed this ability and I thought the community could benefit from it. Please let me know if there are any issues with this PR and I will update them.

kimmobrunfeldt commented 6 years ago

I think this looks otherwise good but this location is still missing the headers parameter: https://github.com/alvarcarto/url-to-pdf-api/blob/1c074f9a73b9c0e03fb85bf97a3e5081fd75023e/src/http/pdf-http.js#L46

kimmobrunfeldt commented 5 years ago

Thanks for the contribution! This is a good suggestion, but I would rather have something like this implemented: https://github.com/alvarcarto/url-to-pdf-api/pull/99. I don't have currently time into helping in that PR but I like the idea of having full control to the request. It opens up even easier ways to exploit this service to make requests to internal services etc, but that's what the API_KEY is for.