CORS ERROR when navigate between sections

Hi people,

I have some problems with the loading delay of my website. When loads from request there is no problem, but when I navigate between pages, sometimes, data.IsReady is always false and the loading page no change and content has not appear. In networks pannel, appears a problem of CORS. I have the the front hosted in a node server and wordpress in other hosting with apache, etc… Someone could said me what I doing wrong?

Thanks!

url: web url
Repository: GitHub - ferranpuigmar/brutal

Hi @ferran.puigmar, you can enable the rest API requests for all sources in WordPress by allowing them in the header.

Option A

For this open wp-content/plugins/json-api/singletons/api.php

<? header("Access-Control-Allow-Origin: *"); ?>

The above code may or may not work for you, it is depending on your WordPress version. If that does not work for you then you can also do the below steps

Option B

open theme functions.php and paste the below code

function add_cors_http_header(){
    header("Access-Control-Allow-Origin: *");
}
add_action('init','add_cors_http_header');

Ultimately you need to allow the request of the Rest API.

Option C

So you can do that by doing one of the above codes or you can use any plugin that helps to allow the Rest API requests.

Which option worked for you?

  • Option A
  • Option B
  • Option C

0 voters

1 Like