@teamkeel/functions-runtime 0.444.0 → 0.446.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -600,6 +600,21 @@ var s3Client = (() => {
|
|
|
600
600
|
credentials: fromEnv()
|
|
601
601
|
});
|
|
602
602
|
})();
|
|
603
|
+
function rewriteFilesDomain(url) {
|
|
604
|
+
const domain = process.env.KEEL_FILES_DOMAIN;
|
|
605
|
+
if (domain) {
|
|
606
|
+
const override = new URL(domain);
|
|
607
|
+
url.protocol = override.protocol;
|
|
608
|
+
url.hostname = override.hostname;
|
|
609
|
+
url.port = override.port;
|
|
610
|
+
const overridePath = override.pathname.replace(/\/+$/, "");
|
|
611
|
+
if (overridePath && overridePath !== "/") {
|
|
612
|
+
url.pathname = overridePath + url.pathname;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return url;
|
|
616
|
+
}
|
|
617
|
+
__name(rewriteFilesDomain, "rewriteFilesDomain");
|
|
603
618
|
var InlineFile = class _InlineFile {
|
|
604
619
|
static {
|
|
605
620
|
__name(this, "InlineFile");
|
|
@@ -739,7 +754,7 @@ var File = class _File extends InlineFile {
|
|
|
739
754
|
ResponseContentDisposition: "inline"
|
|
740
755
|
});
|
|
741
756
|
const url = await getSignedUrl(s3Client, command, { expiresIn: 60 * 60 });
|
|
742
|
-
return new URL(url);
|
|
757
|
+
return rewriteFilesDomain(new URL(url));
|
|
743
758
|
}
|
|
744
759
|
// Generates a presigned upload URL. If the file doesn't have a key, a new one will be generated
|
|
745
760
|
async getPresignedUploadUrl() {
|
|
@@ -754,7 +769,7 @@ var File = class _File extends InlineFile {
|
|
|
754
769
|
Key: "files/" + this.key
|
|
755
770
|
});
|
|
756
771
|
const url = await getSignedUrl(s3Client, command, { expiresIn: 60 * 60 });
|
|
757
|
-
return new URL(url);
|
|
772
|
+
return rewriteFilesDomain(new URL(url));
|
|
758
773
|
}
|
|
759
774
|
// Persists the file
|
|
760
775
|
toDbRecord() {
|