Enable CORS Request for hostname using IP address


I had my site homepage using ip address (only homepage) as host name and the other part still use usual hostname.

There are error in homepage because CORS Policy.

I try to add_filter in functions.php file but still don’t work. This is the code inside.

add_filter( 'allowed_http_origin', 'add_allowed_origin' );
function add_allowed_origin( $origin ) {
     $origin[] = '';
     return $origin;

Error Message

Access to XMLHttpRequest at http://example.com from origin ‘‘ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

shirley 3 years 2019-12-07T08:07:49-05:00 0 Answers 78 views 0

Leave an answer