From a38373a9392bb8a32e8b1277455d0baa821d6292 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 Aug 2022 15:25:04 +0100 Subject: [PATCH] Attach correct content type to JS files when uploading to object store --- packages/backend-core/src/objectStore/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/backend-core/src/objectStore/index.ts b/packages/backend-core/src/objectStore/index.ts index fe9be90659..774018b6df 100644 --- a/packages/backend-core/src/objectStore/index.ts +++ b/packages/backend-core/src/objectStore/index.ts @@ -178,6 +178,14 @@ export const streamUpload = async ( const objectStore = ObjectStore(bucketName) await makeSureBucketExists(objectStore, bucketName) + // Set content type for certain known extensions + if (filename?.endsWith(".js")) { + extra = { + ...extra, + ContentType: "application/javascript", + } + } + const params = { Bucket: sanitizeBucket(bucketName), Key: sanitizeKey(filename),