-
Notifications
You must be signed in to change notification settings - Fork 76
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
HPE_INVALID_HEADER_TOKEN - NodeJS v12 #75
Comments
As you can see the discussion, it is related to the core package brings by node. Nothing we can do here to solve the issue. |
But the header is auto-generated from the Woocommerce rest API. |
I do not think the invalid header is generated by this package. For the header, you can change the header by passing axiosConfig to the constructor. import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api";
const api = new WooCommerceRestApi({
url: "http://example.com",
consumerKey: "ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
consumerSecret: "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
version: "wc/v3",
axiosConfig: {
header: {
'content-type': 'application/json'
}
}
}); |
Thank you for your help, but I removed this flag and used the axiosConfig that you recommended, and I'm still getting this error. Obs: I replaced some private infos with 'x' The only way that it worked for me was using the |
In this case, I think the invalid header is come from the response. As node v12 changed the behavior of http parser to be more strict than before, adding the flags seem to be the only options. |
All my requests using NodeJS v12 are returning Parse Error, and I think this is probably because of space in the header.
There are some discussions related here.
I had to downgrade my NodeJS to v10 and use the flag --insecure-http-parser to make it work.
The text was updated successfully, but these errors were encountered: