You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i wanted to create a customer account sending data from frontend to my wordpress woocommerce restful api and i have this error.
Access to XMLHttpRequest at '[http://localhost:3080/wp-json/wc/v3/customers?oauth_consumer_key=ck_xxx&oauth_nonce=WFJEpYVFEoL2tQjX10vfJWrjl3ksFav0&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1641581338&oauth_version=1.0&oauth_signature=x6eRfi7mO1F%2FfJT34hamqd%2Bwux%2BMKFx8SVViayUDIgE%3D](http://localhost:3080/wp-json/wc/v3/customers?oauth_consumer_key=ck_ca8dc3da04a18c79601e7b49c6e8e216da06cf82&oauth_nonce=WFJEpYVFEoL2tQjX10vfJWrjl3ksFav0&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1641581338&oauth_version=1.0&oauth_signature=x6eRfi7mO1F%2FfJT34hamqd%2Bwux%2BMKFx8SVViayUDIgE%3D)' from origin '[http://localhost:3000](http://localhost:3000/)' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Strangely, when querying a specific few WP/WC rest endpoints the CORS issue seems to come up. I discovered that when NOT fetching these endpoints with basic auth (as is the default setting), but via the query string instead (which does mean exposing the consumer key and secrets via URL), the CORS issue does not seem to come up.
Using this library that would look like:
const api = new WooCommerceRestApi({
url: shopSettings?.url,
consumerKey: shopSettings?.consumer_key,
consumerSecret: shopSettings?.consumer_secret,
version: "wc/v3", queryStringAuth: true,
});
i wanted to create a customer account sending data from frontend to my wordpress woocommerce restful api and i have this error.
here is my post code
anyone facing this problem, how do i bypass the CORS policy ? i am testing on localhost
The text was updated successfully, but these errors were encountered: