fix: disable forcePathStyle for DigitalOcean Spaces to ensure correct CORS behavior

This commit is contained in:
pradeepkumar
2026-04-08 14:03:29 +05:30
parent 99ff978247
commit f468d403e2

View File

@@ -42,7 +42,11 @@ export class UploadService {
// Add custom endpoint for S3-compatible services (Contabo, MinIO, DigitalOcean, etc.) // Add custom endpoint for S3-compatible services (Contabo, MinIO, DigitalOcean, etc.)
if (this.endpoint) { if (this.endpoint) {
s3Config.endpoint = 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); this.s3Client = new S3Client(s3Config);