• Resolved bobby.noonan

    (@bobbynoonan)


    I updated my site, and not I’m getting an error “Failed to crop image”. I checked the DevTools, and I see the following:

    Access to XMLHttpRequest at 'https://www._____.com/wp-json/aiarc/v1/crop' from origin 'https://admin._____.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
    
    

    Failed to load resource: net::ERR_FAILED https://www._____.com/wp-json/aiarc/v1/crop

    Any help would be great. Thanks.

Viewing 2 replies - 16 through 17 (of 17 total)
  • Plugin Author joppuyo

    (@joppuyo)

    Its’ looks like there’s a portion of the URL missing, it should be https://admin.***.com/wp-json/aiarc/v1/get/12807, not https://admin.***.com/aiarc/v1/get/12807

    Maybe you could try to modify the rest_url filter with the following code:

    add_filter('rest_url', function($url) {
        $url = str_replace('www.***.com', 'admin.***.com', $url)
        return $url;
    });

    That should preserve the wp-json endpoint in the URL

    Thread Starter bobby.noonan

    (@bobbynoonan)

    Viola! I think it works. I had to remove all of the other code that you suggested, and used your code (but had to add a semi-colon at after the str_replace):

    add_filter('rest_url', function($url) {
        $url = str_replace('www.***.com', 'admin.***.com', $url);
        return $url;  
    });

    Thank you again for all your help with this. I’m glad that I can now continue to update the plugin with the latest version, and not have to worry about issues. Take Care.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Failed to crop image — CORS Policy issue’ is closed to new replies.