问题
I have tried every possible code by following this post but code give me following error
XMLHttpRequest cannot load https://api.cloudinary.com/cloud_name/resources/image. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.
Code (1)
$.get('https://app_key:app_secret@api.cloudinary.com/cloud_name/resources/image');
Code (2)
$.get('https://api.cloudinary.com/cloud_name/resources/image');
For both it fails to authenticate.
Note: I am not using any server side programming. Please give me any client side solution/code.
回答1:
By $.get(...)
I understand that you're performing this call on the client side (jQuery code). This means that you're revealing your account's api_secret
to your users, they can get your Cloudinary account's credentials with a simply "View source" of your page, then they'll be able to gain full control over your account, including uploading, renaming and even deleting resources. As you probably don't want that to happen, you should either perform this on a server-side only, or use the client-side (unsigned) method of returning all resources sharing a certain tag. For more information:
https://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-
来源:https://stackoverflow.com/questions/36175232/get-list-of-images-from-cloudinary-using-javascript-or-jquery