Skip to content

Commit

Permalink
feat: redirect to cdn when available
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Dec 20, 2024
1 parent 0e12469 commit 534c2e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ AWS_S3_BUCKET=
AWS_S3_REGION=
AWS_S3_ENDPOINT=
FF_URL=https://feature-flags.decentraland.org
ATLAS_SERVER_URL=
ATLAS_SERVER_URL=
CDN_URL=
9 changes: 4 additions & 5 deletions src/modules/s3/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ export async function createS3Component(components: {
const secretAccessKey = await config.getString('AWS_SECRET_ACCESS_KEY')
const bucketName = await config.getString('AWS_S3_BUCKET')
const endpoint = await config.getString('AWS_S3_ENDPOINT')

console.log('S3 Configuration')
console.log(`REGION=${region}`)
console.log(`BUCKET_NAME=${bucketName}`)
console.log(`ENDPOINT=${endpoint}`)
const cdnUrl = await config.getString('CDN_URL')

if (!bucketName) {
componentLogger.warn(
Expand Down Expand Up @@ -178,6 +174,9 @@ export async function createS3Component(components: {

async function getFileUrl(version: string): Promise<string> {
const key = `tiles/${version}/latest.json`
if (cdnUrl) {
return `${cdnUrl}/${key}`
}
return endpoint
? `${endpoint}/${bucketName}/${key}`
: `https://${bucketName}.s3.amazonaws.com/${key}`
Expand Down

0 comments on commit 534c2e3

Please sign in to comment.