url-to-pdf-api icon indicating copy to clipboard operation
url-to-pdf-api copied to clipboard

Added option to override request

Open khartnett opened this issue 5 years ago • 4 comments

This change allows overriding the request, so you can render a page that uses a post request. Example:

curl -X POST \
  https://url-to-pdf-api.herokuapp.com/api/render \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{ "url": "https://en.wikipedia.org/w/index.php", "request": { "method":"POST", "headers": { "cache-control": "no-cache", "content-type": "application/x-www-form-urlencoded" }, "postData": "search=pdf&title=Special%3ASearch&go=Go" } }'

khartnett avatar Feb 25 '19 18:02 khartnett

Thanks for the contribution. I think this is a great idea.

I don't have currently time to help with this 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.

kimmobrunfeldt avatar May 14 '19 10:05 kimmobrunfeldt

I have a fork of this project I maintain for an internal app my company has. I've had to modify this so that it allows a JSON POST body that the app will make rather than.

I added a field called postJsonData and useJsonPost, which modifies the very first request to...well POST the provided json to the target. We use this to get a specific rendered HTML page based on the payload we send it.

This doesn't look like it's gotten any traction, but I'd love to see this merged into the project as otherwise I have to maintain a constantly-rebased fork.

Here's the meat of the change. image

oliverkane avatar Jun 14 '20 16:06 oliverkane

its not make sense create a service that we cant pass a authorization to it. Why not accept the pr? its just a simple thing...

lucawen avatar Aug 24 '20 20:08 lucawen

For those who are looking for a tool that has this feature, I've been using this micro-service with great success. I think if the authors don't wish to add it, that is fine. The whole point of open source stuff is we can fix it/add it ourselves or swap it out.

https://github.com/thecodingmachine/gotenberg

oliverkane avatar Oct 07 '20 14:10 oliverkane