-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcors.js
More file actions
34 lines (33 loc) · 807 Bytes
/
cors.js
File metadata and controls
34 lines (33 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const AWS = require('aws-sdk');
const s3 = new AWS.S3({endpoint: 'https://s3.filebase.com', signatureVersion: 'v4'});
s3.listBuckets(function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
var params = {
Bucket: data['Buckets'][0]['Name'], // I suggest you edit this to a string
CORSConfiguration:
{
CORSRules:
[
{
AllowedHeaders: ["*"],
AllowedMethods: ["PUT", "POST"],
AllowedOrigins: ["*"]
},
{
AllowedMethods: ["GET"],
AllowedOrigins: ["*"]
}
]
}
};
s3.putBucketCors(params, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
console.log("Success! Edited CORS on:", params.Bucket);
}
});
}
});