-
Notifications
You must be signed in to change notification settings - Fork 9
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 set headers for the gotenberg request? #26
Comments
Hm... If you are using plain JavaScript, you can easily hack into For example (don't have possibility to check the code right now, but it should work): const auth = (value) => (request) => ({
...request,
headers: {
...request.headers,
'Authorization': value,
},
})
const toPDF = pipe(
gotenberg('https://cloud-run'),
auth('Bearer abc'),
convert,
office,
set(filename('result.pdf')),
please
); Also: This is undocumented, because I didn't have time then and then I just forgot ._. But GotenbergClient could be a plain object with fields You can check signature of GotenbergClient is responsible for HTTP requests to Gotenberg. |
Honestly I don't want to add new functionality support to default GotenbergClient, but maybe introduce more convenient way to hack into chain, for advanced usage? For example, some sort of function Like const toPDF = pipe(
gotenberg('https://cloud-run'),
adjust({ headers: { 'Authorization': 'Bearer abc' } }),
convert,
office,
set(filename('result.pdf')),
please
); Which will work exactly like code snippet in my previous comment. What do you think? |
You know, I just checked my codes, and your code in your initial question even might work in some cases (maybe for URL conversions) :) If But it will override default headers, so, I guess it will break files sent... I think I can change this part so it will merge headers, not override them :) |
The first solution worked perfectly! Thanks a lot! The |
Cool, but I've published new version 0.7.0 nonetheless :) It fixes config merging and introduces new function As well as my code from this comment, with |
In the README there is an example on how to set the header for the request gotenberg does to an external URL, but there isn't any reference on how to set a header to the request to gotenberg itself.
Maybe if we could pass it to the gotenberg call like this?
The text was updated successfully, but these errors were encountered: