0
我一直在嘗試一天,但我無法修復它。它在控制檯中出現了這個錯誤。無法上傳圖片到S3使用Froala
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.
}
代碼這是亞馬遜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>
`
我在這裏錯過了什麼嗎?請幫助
我確實試過你建議我。它不起作用。仍然有相同的錯誤。 *是否允許每個通配符? – Letmetake
亞馬遜不允許'*'爲AllowedOrigin。您應該放置該網頁的網址。 – st3fan
現在我得到了其他錯誤。這是「選項https://s3-ap-southeast-1.amazonaws.com/flagfrog-article-cloud 403(禁止)」。當我點擊它時,它會顯示「我們計算的請求籤名與您提供的簽名不匹配,請檢查您的密鑰和簽名方法。」任何建議?非常感謝 – Letmetake