I have this wordpress site with a plugin called JSON API. This plugin provides a JSON format for the content that is in the wordpress. I was able to enable CORS on the wordp
Using Wordpress 5.2.3 - whilst using GET and POST externally, the following finally opened sesame for me. I tried all of the answers above (to no avail) before finding this solution that worked for my case.
add_action( 'rest_api_init', function () {
add_action( 'rest_pre_serve_request', function () {
header( 'Access-Control-Allow-Headers: Authorization, Content-Type, X-WP-Wpml-Language', true );
header("Access-Control-Allow-Origin: *");
} );
}, 15 );
Hopefully WordPress will have an official doggy door-flap for CORS control in the future.