Closed sauravcd02 closed 5 years ago
Add this code to youre functions.php --> function add_cors_http_header(){ header("Access-Control-Allow-Origin: *"); header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS, READ'); header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token,authorization,XMLHttpRequest, user-agent, accept'); header("Access-Control-Allow-Credentials: true");
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
status_header(200);
exit();
}
} add_action('init','add_cors_http_header');
Thnak you for your quick response. I have used the above code, in my thems/functions.php file but i have found this errors.
Change header("Access-Control-Allow-Origin: *"); to header("Access-Control-Allow-Origin: http://localhost:8100");
Thanks this worked
Happy to hear that!
This library is now deprecated, you should try https://github.com/woocommerce/woocommerce-rest-api-js-lib
i am trying to test ionic app on browser with wc-api-node. it show me origin blocked by CORS issue. i have add proxies still same issue .