How to enable CORS on a cPanel account
There is several ways to enable CORS (Cross-Origin Resource Sharing). On a cPanel server / account you need to do it with htaccess inside the domain's account. You need to edit the htaccess file and add one of these three lines:
This is the riskiest as it allows all domain cross resource sharing:Header set Access-Control-Allow-Origin "*"
The safest way is to choose the domain to cross share like this:Header always set Access-Control-Allow-Origin "yourdomain.com"
Or you may need to add the mod headers module:<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "yourdomain.com"
</IfModule>
We suggest trying it with the domain and * for testing purposes.
The other ways include adding PHP code in the WordPress functions.php, which we were not able to make work.
And you can add code in the SSL apache core, which we also were not able to make work.
If adding Header always set Access-Control-Allow-Origin "yourdomain.com" does not work, it's likely not a CORS issue.