From f468d403e2028f739bd4f49a3775b6ca3ee32059 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 8 Apr 2026 14:03:29 +0530 Subject: [PATCH] fix: disable forcePathStyle for DigitalOcean Spaces to ensure correct CORS behavior --- src/upload/upload.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/upload/upload.service.ts b/src/upload/upload.service.ts index 51b79ea..3af17c7 100644 --- a/src/upload/upload.service.ts +++ b/src/upload/upload.service.ts @@ -42,7 +42,11 @@ export class UploadService { // Add custom endpoint for S3-compatible services (Contabo, MinIO, DigitalOcean, etc.) if (this.endpoint) { s3Config.endpoint = this.endpoint; - s3Config.forcePathStyle = true; // Required for most S3-compatible services + // DigitalOcean Spaces: use virtual-hosted-style (bucket.region.digitaloceanspaces.com) + // so CORS rules on the bucket are properly applied. + // Path-style URLs (region.digitaloceanspaces.com/bucket) bypass CORS on DO Spaces. + const isDigitalOceanSpaces = this.endpoint.includes('digitaloceanspaces.com'); + s3Config.forcePathStyle = !isDigitalOceanSpaces; } this.s3Client = new S3Client(s3Config);