Error alert JS: 403 Forbidden in Wordpress

0

I have a problem on a wordpress website, on each product page, when I enter, an alert appears showing an error 403 Forbidden. It comes from the file admin-ajax.php In Internet Explorer and in Mobile it almost always comes out.

I can not figure out where it comes from. It can be a problem with permissions, htaccess ... but I've tried everything.

See image

An example url: link

Thank you!

    
asked by Ito Martinez Alonso 26.12.2017 в 01:10
source

2 answers

0

The reason for the error 403 is that it is not sending headers. Since you are making a CORS request, you can not send any custom header unless the server enables these headers by adding Access-Control-Allow-Headers to the response.

In a pre-selected request, the client makes 2 requests to the server. The first is pre-verification (with the OPTION method) and the second is the actual request. The server sends the Access-Control-Allow-Headers header in response to the preflight request. Therefore, it allows the sending of some headers. This way, your POST request can work, because the POST request is a prior request. But for a GET request, there is no pre-verification to gather the Access-Control-Allow-Headers header. Then, the browser does not send your custom headers.

A solution:

Add in your php admin-ajax.php file before printing anything with the, example:

header('Access-Control-Allow-Origin: *');
echo json_encode($resultado);
    
answered by 26.12.2017 в 02:03
0

I think it's going well!

  • I added to the functions.php:

add_filter ('allowed_http_origins', 'add_allowed_origins');

function add_allowed_origins ($ origins) {     $ origins [] = ' link ';     return $ origins; }

-I added the .htaccess:     Header set Access-Control-Allow-Origin "*"

And I updated the plugins again.

Some of the 3 resulted:)

Thanks

    
answered by 26.12.2017 в 03:58