Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fdr): public s3 file uploads go through cloudfront #2042

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion servers/fdr/src/services/s3/S3Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,23 @@ export class S3ServiceImpl implements S3Service {
input.ContentType = "image/svg+xml";
}
const command = new PutObjectCommand(input);
return {
const result = {
url: await getSignedUrl(
isPrivate ? this.privateDocsS3 : this.publicDocsS3,
command,
{ expiresIn: 3600 }
),
key,
};
if (!isPrivate) {
try {
const url = new URL(result.url);
result.url = result.url.replace(url.host, this.publicDocsCDNUrl);
} catch (error) {
console.error("Failed to replace S3 URL with CDN URL:", error);
}
}
return result;
}

async getPresignedApiDefinitionSourceDownloadUrl({
Expand Down
Loading