From 534c2e30b5d5a5da3a9ca5fb8d9957cc4b214d4f Mon Sep 17 00:00:00 2001 From: Juan Cazala Date: Fri, 20 Dec 2024 14:40:28 -0300 Subject: [PATCH] feat: redirect to cdn when available --- .env.defaults | 3 ++- src/modules/s3/component.ts | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.defaults b/.env.defaults index 29add02..9222327 100644 --- a/.env.defaults +++ b/.env.defaults @@ -20,4 +20,5 @@ AWS_S3_BUCKET= AWS_S3_REGION= AWS_S3_ENDPOINT= FF_URL=https://feature-flags.decentraland.org -ATLAS_SERVER_URL= \ No newline at end of file +ATLAS_SERVER_URL= +CDN_URL= \ No newline at end of file diff --git a/src/modules/s3/component.ts b/src/modules/s3/component.ts index c01e451..1c1f6d3 100644 --- a/src/modules/s3/component.ts +++ b/src/modules/s3/component.ts @@ -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( @@ -178,6 +174,9 @@ export async function createS3Component(components: { async function getFileUrl(version: string): Promise { const key = `tiles/${version}/latest.json` + if (cdnUrl) { + return `${cdnUrl}/${key}` + } return endpoint ? `${endpoint}/${bucketName}/${key}` : `https://${bucketName}.s3.amazonaws.com/${key}`