![](/img/trans.png)
[英]Why am I having the "CORS header ‘Access-Control-Allow-Origin’ missing" error when accessing an AWS S3 bucket?
[英]AWS S3 bucket CORS settings not fixing the error
在我的 AWS S3 存儲桶上https://qr-code-page.s3.eu-central-1.amazonaws.com/S3+Buckets/index.html (在手機模式下查看以獲得最佳體驗)單擊時我會調用外部鏈接在發送按鈕上。
這會在控制台中引發 CORS 錯誤,即使我認為我已經在權限選項卡中添加了正確的 CORS 規則。
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
但這似乎並不能解決問題,錯誤仍然存在。 關於下一步做什么的任何建議?
ajax 調用如下所示:
function sendform() {
var description = document.getElementById("problemDetails").value ==
null ? '' : document.getElementById("problemDetails").value
console.log('description = '+description)
$.ajax({
method: "GET",
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': 'https://qhtzkxv8aj.execute-api.eu-
central-1.amazonaws.com/Live/'
},
url: "https://qhtzkxv8aj.execute-api.eu-central-1.amazonaws.com/Live/environment="+getParam('environment')+"&function="+getParam('function')+"&location="+getParam('location')+"&tasktype="+getParam('tasktype')+"&subjecttype="+getParam('subjecttype')+"&description="+description,
success: function (data) { console.log('succes; ' + data) },
failure: function (data) { console.log('failure; ' + data) },
我建議您在控制台中打印請求的 URL 並查看是否可以直接訪問該鏈接,上面的 CORS 配置應該可以完成工作。
還要檢查開發工具中 chrome.network 檢查器下的響應詳細信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.