0
私はReactS3Uploaderを使用して、ブラウザからs3にファイルをアップロードします。マイCORSルールは以下のとおりです。<AllowedHeader> Authorization</ AllowedHeader> CORSルールでバケットにファイルをアップロード
<?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>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
私は<AllowedHeader>*</AllowedHeader>
に<AllowedHeader>Authorization</AllowedHeader>
を変更する場合は、everytingが正常に動作します。私は<AllowedHeader>Authorization</AllowedHeader>
を使用する場合しかし、私はエラーを持っている:後
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
は私ReactS3Uploaderです:後
<ReactS3Uploader
signingUrl="/s3/sign"
signingUrlMethod="GET"
//accept="image/*"
s3path="/test"
//signingUrlHeaders={{ additional: headers }}
//signingUrlQueryParams={{ additional: query-params }}
//signingUrlWithCredentials={ true } // in case when need to pass authentication credentials via CORS
uploadRequestHeaders={{ 'x-amz-acl': 'public-read' }} // this is the default
contentDisposition="auto"
scrubFilename={(filename) => filename.replace(/[^\w\d_\-.]+/ig, '')}
server="http://localhost:3001" />
は、署名のための私のサーバー側のコードです:
app.use('/s3', require('react-s3-uploader/s3router')({
bucket: "bucktmodel",
region: 'us-east-1', //optional
signatureVersion: 'v2', //optional (use for some amazon regions: frankfurt and others)
//headers: {'Access-Control-Allow-Origin': '*'}, // optional
ACL: 'private', // this is default
uniquePrefix: true // (4.0.2 and above) default is true, setting the attribute to false preserves the original filename in S3
}));