【发布时间】:2015-11-24 07:48:12
【问题描述】:
我正在编写 https://sendevidence.org 并试图让人们直接上传到 S3 存储桶。我来了
XMLHttpRequest cannot load https://sendevidence-any-agency.s3-us-west-2.amazonaws.com/. The request was redirected to 'https://sendevidence.org/?bucket=sendevidence-any-agency&key=uploads%2Ftest.pdf&etag=%222bb3099f895cbdd3715840357f65f0af%22', which is disallowed for cross-origin requests that require preflight.
上传时。
我的 S3 存储桶:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<ExposeHeader>ETag</ExposeHeader>
</CORSRule>
</CORSConfiguration>
我的 Nginx CORS:
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
如何消除此错误?文件本身确实会上传到 S3。
【问题讨论】: