【发布时间】:2017-07-10 15:15:46
【问题描述】:
我已经尝试了一天,但我无法修复它。它在控制台中出现此错误。
XMLHttpRequest cannot load https://s3-us-east-2.amazonaws.com/My-bucket. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
这是我在 Angular2 上的代码
imageUploadToS3: {
bucket: 'flagfrog-article-cloud',
region: 's3-us-east-2',
keyStart: 'article-image/',
params: {
acl: 'public-read', // ACL according to Amazon Documentation.
AWSAccessKeyId: 'AKIAJEMDZVXVLMPDNA4A', // Access Key from Amazon.
policy: 'Policy1498724219240', // Policy string computed in the backend.
signature: 'flagfrogweb', // Signature computed in the backend.
}
这是我在 Amazon S3 上的 CORS 配置。
`<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
`
我在这里遗漏了什么吗?请帮忙
【问题讨论】:
标签: angular amazon-s3 xmlhttprequest froala