I'm trying to send a POST
to woocommerce / wordpress using the woocommerce-api API, but only I get the error 401
that says:
Fetch API can not load link ... Response for preflight has invalid HTTP status code 401
TypeError: Failed to fetch at TypeError (native)
I have already tried to add permission via htaccess
with:
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin: "http://localhost:3000"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
Header add Access-Control-Allow-Headers: "Content-Type"
Header add Access-Control-Allow-Credentials: "true"
</IfModule>
I also tried right in header.php
of my theme:
header("Access-Control-Allow-Origin: *");
And also in the file functions.php
:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: *");
POST
is being performed from a REACT
plication application through the local server that is made available through react-scripts start
When I click on the link
provided by the error I get the following JSON
:
{"code":"woocommerce_rest_authentication_error","message":"Assinatura inv\u00e1lida - a assinatura fornecida n\u00e3o corresponde.","data":{"status":401}}
The API
keys already have permission and read and write.