我正在尝试使用 Uploadcare 的 REST API 删除图像,我所做的与文档和这篇文章中所说的完全一样,但仍然无法删除图像,这是我的代码:
的HTML:
<html>
<script charset="utf-8" src="https://ucarecdn.com/libs/widget/3.2.2/uploadcare.full.min.js"></script>
<body>
<div class="main">
</div>
<div>
<button class="uploader">Upload an image</button>
<input class="deletet" />
<button class="getit">delete something</button>
</div>
</body>
<footer>Developep by Francisco Jimenez</footer>
</html>
的JavaScript:
function deleteb(uuid){
$.ajax({`
url: "https://api.uploadcare.com/files/"+uuid+"/",`
type: "DELETE",
headers: { "Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Accept": "application/vnd.uploadcare-v0.5+json",
"Access-Control-Allow-Methods": "HEAD, GET, OPTIONS",
"Authorization": "Uploadcare.Simple publickey:privatekey"
},
success: function(result){
alert("yessss");
console.log(result);
},
error: function (result){
alert("ouuuh");
console.log(result);
}
});
}
我不断得到的响应是::Cross-Origin Request Blocked
同源策略不允许在https://api.uploadcare.com/files/c2e166b5-17b9-493f-bf8c-b33da27842ca~1/读取远程资源。(原因:缺少 CORS 标头“Access-Control-Allow-Origin”)。
我做错了什么?