-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-bucket.ts
33 lines (29 loc) · 770 Bytes
/
update-bucket.ts
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
import aws from 'aws-sdk'
import type { LoaderFunction } from '@remix-run/node'
import * as dotenv from 'dotenv'
dotenv.config()
const s3 = new aws.S3({
endpoint: process.env.S3_ENDPOINT,
accessKeyId: process.env.S3_KEY,
secretAccessKey: process.env.S3_SECRET,
signatureVersion: 'v4',
})
const config = {
AllowedHeaders: ['content-type'],
AllowedMethods: ['PUT'],
AllowedOrigins: ['*'],
}
const bucketParams = {
Bucket: process.env.S3_BUCKET as string,
CORSConfiguration: { CORSRules: new Array(config) },
}
s3.putBucketCors(bucketParams, function (err, data) {
if (err) {
console.log('Error', err)
} else if (data) {
console.log('Success', JSON.stringify(data))
}
})
export const loader: LoaderFunction = async () => {
return {}
}