Favorite link gives "Error loading listing"

This topic contains 3 replies, has 2 voices, and was last updated by  Stiofan O’Connor 9 years, 6 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #20230

    Greg Mount
    Free User
    Post count: 82

    When a logged in user tries to favorite a listing on http://www.animalequity.org, the following error appears in a modal:

    “Error loading listing”

    The console shows the following additional info:

    “Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.animalequity.dev/?geodir_signup=true. This can be fixed by moving the resource to the same domain or enabling CORS.”

    This site has FORCE_SSL_ADMIN enabled, if that helps. What could be causing this error?

    #20234

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Greg,

    This is to stop cross domain scripting, http/https and www. v non www. are thought of as different domains, you have to tell the script that it’s ok to accept requests from these other domains. I have not tested this but i think this should work, let me know either way:

    add this to your child theme functions file

    
    
    add_action('wp_ajax_geodir_ajax_action', "geodir_ajax_origin_allow");
    add_action( 'wp_ajax_nopriv_geodir_ajax_action', 'geodir_ajax_origin_allow' );
    function geodir_ajax_origin_allow(){
    header('Access-Control-Allow-Origin: http://www.animalequity.org');
    }

    P.S. I just noticed one domain says .org and one .dev, this could be just a local hosts issue? I’m not exactly sure of ur setup here, if you could explain i could help better, or you might also have to add this line below the first header.

    header('Access-Control-Allow-Origin: http://www.animalequity.dev');

    Thanks,

    Stiofan

    #20236

    Greg Mount
    Free User
    Post count: 82

    Thanks Stiofan. Adding your code to functions.php didn’t work, but I can confirm that FORCE_SSL_ADMIN is the cause.

    You can ignore the different domains. I pasted the console output from the development site instead of production. The issue is present in both production and development.

    #20251

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    added a fix for this in core and added to your site now.

    Stiofan

Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket