I have a WordPress site that I’ve developed a mobile app for, in the app I’d like to download some of the WordPress image files to store locally on the users device but I’m battling with CORS.
I’ve added the necessary header to the .htaccess as I’ve purged the CloudFlare cache as per the guide but it’s still not working and failing with the error that CORS needs to be enabled, I’m using this to test… Online Web service testing tool - Automated API testing
Any idea’s on what I’m missing?
Cloudflare won’t strip CORS headers, so likely you have not set them correctly at your origin.
To check your domain without Cloudflare to ensure the headers exist, use cURL at the commandline:
curl -svo /dev/null https://example.com/my-cors-url --connect-to ::188.8.131.52 --ipv4
https://example.com/my-cors-url with the URL where you added your CORS headers and
184.108.40.206 with your origin server IP.
If you don’t see the CORS headers in that response, then your .htaccess setting hasn’t worked.
Thanks for the reply, looks like the problem is actually my hosting provider. I spoke to their support and they confirmed that they do not allow CORS on shared hosting.
There’s a couple of examples of code in our dev docs you can use for inspiration:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.