summary refs log tree commit diff
diff options
context:
space:
mode:
authorohmwraith <vs.ohmwraith@gmail.com>2026-04-24 04:33:21 +0300
committerRory& <root@rory.gay>2026-04-29 19:35:38 +0200
commit50c7da9872fcb12482d1290ea3c1f2d3101193a3 (patch)
tree159c0d471783804a6cb88a1f4321e92ec3bb13f1
parentRegister: cache blocked IPs (diff)
downloadserver-ts-50c7da9872fcb12482d1290ea3c1f2d3101193a3.tar.xz
Implement S3 force path-style support
-rw-r--r--src/cdn/util/S3Storage.ts3
-rw-r--r--src/cdn/util/Storage.ts9
2 files changed, 10 insertions, 2 deletions
diff --git a/src/cdn/util/S3Storage.ts b/src/cdn/util/S3Storage.ts

index 22afd88e..fb378836 100644 --- a/src/cdn/util/S3Storage.ts +++ b/src/cdn/util/S3Storage.ts
@@ -33,10 +33,11 @@ export class S3Storage implements Storage { private region: string, private bucket: string, private endpoint: string, + private forcePathStyle: boolean, private basePath?: string, ) { const { S3 } = require("@aws-sdk/client-s3"); - this.client = new S3({ region: region, endpoint: endpoint }); + this.client = new S3({ region: region, endpoint: endpoint, forcePathStyle: forcePathStyle }); } isFile(path: string): Promise<boolean> { return this.exists(path); diff --git a/src/cdn/util/Storage.ts b/src/cdn/util/Storage.ts
index f90d5d1b..8b7602cb 100644 --- a/src/cdn/util/Storage.ts +++ b/src/cdn/util/Storage.ts
@@ -82,8 +82,15 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) { location = undefined; } + // if false, the bucket name is used as a subdomain + const forcePathStyle = process.env.STORAGE_FORCE_PATH_STYLE === "true"; + + if (process.env.STORAGE_FORCE_PATH_STYLE === undefined) { + console.warn(`[CDN] STORAGE_FORCE_PATH_STYLE unconfigured for S3 provider, defaulting to use virtual-hosted style...`); + } + const { S3Storage } = require("./S3Storage"); - storage = new S3Storage(region, bucket, endpoint, location); + storage = new S3Storage(region, bucket, endpoint, forcePathStyle, location); } export { storage };