@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 CHANGED
@@ -652,6 +652,21 @@ var s3Client = (() => {
652
652
  credentials: (0, import_credential_providers.fromEnv)()
653
653
  });
654
654
  })();
655
+ function rewriteFilesDomain(url) {
656
+ const domain = process.env.KEEL_FILES_DOMAIN;
657
+ if (domain) {
658
+ const override = new URL(domain);
659
+ url.protocol = override.protocol;
660
+ url.hostname = override.hostname;
661
+ url.port = override.port;
662
+ const overridePath = override.pathname.replace(/\/+$/, "");
663
+ if (overridePath && overridePath !== "/") {
664
+ url.pathname = overridePath + url.pathname;
665
+ }
666
+ }
667
+ return url;
668
+ }
669
+ __name(rewriteFilesDomain, "rewriteFilesDomain");
655
670
  var InlineFile = class _InlineFile {
656
671
  static {
657
672
  __name(this, "InlineFile");
@@ -791,7 +806,7 @@ var File = class _File extends InlineFile {
791
806
  ResponseContentDisposition: "inline"
792
807
  });
793
808
  const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
794
- return new URL(url);
809
+ return rewriteFilesDomain(new URL(url));
795
810
  }
796
811
  // Generates a presigned upload URL. If the file doesn't have a key, a new one will be generated
797
812
  async getPresignedUploadUrl() {
@@ -806,7 +821,7 @@ var File = class _File extends InlineFile {
806
821
  Key: "files/" + this.key
807
822
  });
808
823
  const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
809
- return new URL(url);
824
+ return rewriteFilesDomain(new URL(url));
810
825
  }
811
826
  // Persists the file
812
827
  toDbRecord() {