简体   繁体   English

AWS S3 存储桶 CORS 设置未修复错误

[英]AWS S3 bucket CORS settings not fixing the error

on my AWS S3 bucket https://qr-code-page.s3.eu-central-1.amazonaws.com/S3+Buckets/index.html (view in phone mode for optimal experience) Im calling an external link when clicked on the Send button.在我的 AWS S3 存储桶上https://qr-code-page.s3.eu-central-1.amazonaws.com/S3+Buckets/index.html (在手机模式下查看以获得最佳体验)单击时我会调用外部链接在发送按钮上。

This throws a CORS error in the console, even though I think I have added the proper CORS rules in the permissions tab.这会在控制台中引发 CORS 错误,即使我认为我已经在权限选项卡中添加了正确的 CORS 规则。

[
{
    "AllowedHeaders": [
        "*"
    ],
    "AllowedMethods": [
        "GET",
        "HEAD"
    ],
    "AllowedOrigins": [
        "*"
    ],
    "ExposeHeaders": [],
    "MaxAgeSeconds": 3000
}
]

but this doesn't seem to do the trick, the error still persists.但这似乎并不能解决问题,错误仍然存在。 any recommendations on what to do next?关于下一步做什么的任何建议?

the ajax call looks like this: 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) },

I suggest you print the requested URL in the console and see if you can access that link directly, the CORS config above should do the work.我建议您在控制台中打印请求的 URL 并查看是否可以直接访问该链接,上面的 CORS 配置应该可以完成工作。

also check respond details under chrome.network inspector in the dev tools还要检查开发工具中 chrome.network 检查器下的响应详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM