![](/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.