-
Notifications
You must be signed in to change notification settings - Fork 51
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
Webhook Plugin - Unable to use Custom Header #556
Comments
Any chance you can comment on this @martijnvdbrug |
Interesting, thats definitely not something we check... I will take a look |
Could it be that your env var is undefined? This answer says spaces at the end of a header name arent allowed. Maybe test it out with a hardcoded string first? |
I tried a bunch of things, even upgraded to Vendure 3.1.1. Since it was an option in the plugin example I assumed it may have worked at somepoint. I have issues with types in Typescript but an X-header should be allowed. In another plugin I just use axios and it works. |
I will look in to it! |
Hi @cboothe, I've tried to reproduce your issue, but failed unfortunately: I was able to successfully send a webhook, with custom transformer and the same headers as your example: // These are the headers I used
headers: {
'x-custom-header': 'stringify-custom-header',
'content-type': 'application/json',
authorization: 'Bearer XXXX',
'custom-header': 'true',
} I am also not able to reproduce the behavior with any other seemingly invalid header names. Could the error be thrown somewhere else in your server? Or maybe even the receiving endpoint? Happy to take a look if you can supply a working reproduction, but until then there is not much I can do from this side. (I did publish 1.3.1, which fixes the UI labels) |
@martijnvdbrug Thanks for checking! I did try two different solutions for catching the webhook to see the headers. |
Which plugin/repository is the issue about?
vendure-plugin-webhook
Describe the bug
I am unable to use a custom header. I tried with a custom header as well as the "x-" custom header pattern and both fail after adding to the worker queue. I don't see anywhere in the plugin or Vendure where it checks for invalid header names.
To Reproduce
Use a custom transformer as per the example.
{
headers: {
'content-type': 'application/json',
'authorization': 'Bearer ' + process.env.WEBHOOK_KEY,
'custom-header': 'true'
}
[server] error 1/6/25, 6:59 AM - [WebhookPlugin] Failed to call webhook for event OrderPlacedEvent channel 3: TypeError: custom-header: is not a legal HTTP header name
Expected behavior
Without the custom header it works.
[server] info 1/6/25, 6:58 AM - [WebhookPlugin] Successfully triggered webhook for event OrderPlacedEvent for channel 3 with transformer "Stringify Order events"
Screenshots
Environment
Additional context
[martijnvdbrug] It show this works in the transformer example.
https://plugins.pinelab.studio/plugin/vendure-plugin-webhook/#custom-transformers
The text was updated successfully, but these errors were encountered: