From 843ca5fe23cf65e241bd732f7644ffd23c0caea5 Mon Sep 17 00:00:00 2001 From: geidsonc Date: Fri, 27 Feb 2026 22:27:08 -0300 Subject: [PATCH] fix(enterprise): support custom S3 endpoint configuration - Add OPENCODE_STORAGE_ENDPOINT env var for custom S3-compatible services - Detect endpoint format (virtual hosted vs path style) automatically - Add service: "s3" to AwsClient for S3-compatible providers --- packages/enterprise/src/core/storage.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/enterprise/src/core/storage.ts b/packages/enterprise/src/core/storage.ts index b8030b4f901..28eb338b72a 100644 --- a/packages/enterprise/src/core/storage.ts +++ b/packages/enterprise/src/core/storage.ts @@ -10,7 +10,13 @@ export namespace Storage { } function createAdapter(client: AwsClient, endpoint: string, bucket: string): Adapter { - const base = `${endpoint}/${bucket}` + const normalizedEndpoint = endpoint.replace(/\/$/, "") + const normalizedBucket = bucket.replace(/^\//, "") + + const base = normalizedEndpoint.includes(normalizedBucket) + ? normalizedEndpoint + : `${normalizedEndpoint}/${normalizedBucket}` + return { async read(path: string): Promise { const response = await client.fetch(`${base}/${path}`) @@ -66,12 +72,14 @@ export namespace Storage { function s3(): Adapter { const bucket = process.env.OPENCODE_STORAGE_BUCKET! const region = process.env.OPENCODE_STORAGE_REGION || "us-east-1" + const endpoint = process.env.OPENCODE_STORAGE_ENDPOINT || `https://s3.${region}.amazonaws.com` const client = new AwsClient({ + service: "s3", region, accessKeyId: process.env.OPENCODE_STORAGE_ACCESS_KEY_ID!, secretAccessKey: process.env.OPENCODE_STORAGE_SECRET_ACCESS_KEY!, }) - return createAdapter(client, `https://s3.${region}.amazonaws.com`, bucket) + return createAdapter(client, endpoint, bucket) } function r2() {