问题描述
我已按照但代码给我以下错误
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.
代码(1)
$.get('https://app_key:[email protected]/cloud_name/resources/image');
代码(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.
推荐答案
按 $。get(...)
我知道你在客户端执行此调用(jQuery代码)。这意味着您向用户透露了帐户的 api_secret
,他们可以通过简单的查看来源获取您的Cloudinary帐户的凭据,然后他们就会能够完全控制您的帐户,包括上传,重命名甚至删除资源。由于您可能不希望这种情况发生,您应该仅在服务器端执行此操作,或使用客户端(无符号)方法返回共享特定标记的所有资源。欲了解更多信息:
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-
这篇关于使用JavaScript或JQuery从cloudinary获取图像列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!