Resource URL not working
Hi, I am trying to get the Remote Fetch API to work for our account.
When I append an image URL to the demo URL, I get the image as expected:
But when I replace "demo" in the URL with our own cloud_name, the server returns a 404. The HTTP response has an extra header with error details:
x-cld-error: Resource not found
I've tried to resolve it by changing the settings; toggling "Restricted media types / Fetch URL" seems to make no difference, and all the other fields (Allowed fetch domains etc.) are blank, which I would interpret as "unrestricted". (Tried adding images.ctfassents.net there but that didn't help either.)
-
Official comment
Hi Daniel,
Fetch URLs are disabled by default on all accounts. This is just to prevent malicious users loading unnecessary images.
To enable fetch, please do the following.
- Login to your Cloudinary portal.
- Click on Settings (gear icon towards top right)
- Navigate to the Security tab
- In the section Restricted Media Type, there will be an option named Fetched URL. Uncheck and save.
This will enable Fetch on your account. Here's the setting.
Additionally, we recommend that you consider locking down the fetch targets to a fixed set of domains or a fixed set of referrers.
- Domain restriction will ensure that Cloudinary will only fetch from the set of domains that you whitelist.
- Referrer restriction will ensure that fetch only if the request is being made from a whitelisted source website.
Both the options are on the same Security section of the Cloudinary settings page.
Let me know if this works.
Thanks,
Akshay
-
Hello Akshay,
as mentioned in my original post, I had already unsuccessfully tried to fetch with these restrictions turned off.
I have investigated a bit further, and the problem seems to be related to the Cloudinary cache. After adjusting the settings, I was only able to get images from the CDN after manipulating the URLs to request image sizes which has never been requested before.
It seems that the cache isn't cleared after a settings change, and that is really confusing and should be changed or at least mentioned on the settings page.
0 -
If I understand your comment, you are indicating that when you first fetched the image it was perhaps not available and we sent down a 404. Subsequently, this 404 remained even after the image was available on the remote sever. Was this the behavior that you noticed?
0 -
Hello Akshay, that is correct.
0 -
Thank you, Daniel.
So in this case, it was the not fetch that was an issue but, the removal of 404 cached object. The 404 error is cached based on an exponential backoff algorithm. To ensure you don't run into the problem, the best approach would be to issue a cache invalidation once the original image is available on your remote sever. After uploading the correct image, you can issue a cache invalidation using the explicit method. In this method, ensure that the flag invalidate=true is set. By doing so, the CDN cache will be cleared and you should not see the error.
Let me know if this helps.
0
Post is closed for comments.
Comments
5 comments