Open gabrielgiorisatto opened 4 years ago
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. My suggestion would be check which header cause the issue, then disable that plugins which generate the header.
But the header is auto-generated from the Woocommerce rest API. Is it possible to change the header manually?
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. Example:
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 --insecure-http-parser
flag.
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.