Skip to content

Commit 2db3182

Browse files
authored
fix(fdr): public s3 file uploads go through cloudfront (#2042)
1 parent a4ff3f9 commit 2db3182

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

servers/fdr/src/services/s3/S3Service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,23 @@ export class S3ServiceImpl implements S3Service {
223223
input.ContentType = "image/svg+xml";
224224
}
225225
const command = new PutObjectCommand(input);
226-
return {
226+
const result = {
227227
url: await getSignedUrl(
228228
isPrivate ? this.privateDocsS3 : this.publicDocsS3,
229229
command,
230230
{ expiresIn: 3600 }
231231
),
232232
key,
233233
};
234+
if (!isPrivate) {
235+
try {
236+
const url = new URL(result.url);
237+
result.url = result.url.replace(url.host, this.publicDocsCDNUrl);
238+
} catch (error) {
239+
console.error("Failed to replace S3 URL with CDN URL:", error);
240+
}
241+
}
242+
return result;
234243
}
235244

236245
async getPresignedApiDefinitionSourceDownloadUrl({

0 commit comments

Comments
 (0)