馃摐 Description
The application uses Cloudflare R2 for file uploads via the AWS S3 SDK. The R2 client is initialized with a hardcoded endpoint URL that only works for US/default region buckets. When a bucket is created in the EU region, all upload operations fail because the endpoint URL format is different.
Technical Details :
- The endpoint is hardcoded in libraries/nestjs-libraries/src/upload/r2.uploader.ts (line 26)
- Current endpoint: https://${CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com
- Required EU endpoint: https://${CLOUDFLARE_ACCOUNT_ID}.eu.r2.cloudflare.com
- This affects all R2 operations: simple uploads, multipart uploads, presigned URLs, etc.
馃憻 Reproduction steps
- Set up Cloudflare R2 bucket in EU region:
- Create a Cloudflare R2 bucket with jurisdiction set to "EU"
- Note your Account ID, Access Key, and Secret Access Key
- Configure the application environment variables:
- Attempt to upload a file:
- Start the application
- Navigate to any upload functionality (e.g., media upload, profile picture, etc.)
- Select a file and attempt to upload
- Observe the upload fails
- Check the application logs:
- Look for error messages related to R2/S3 operations
- Errors is
NoSuchBucket: The specified bucket does not exist.
馃憤 Expected behavior
- The file upload should succeed regardless of the bucket region (US, EU, APAC, etc.)
- The S3 client should connect to the correct regional endpoint
- Upload operations (simple upload, multipart upload, presigned URLs) should work correctly
- Users should see a success message and the uploaded file should be accessible
- The application should return the correct file URL
馃憥 Actual Behavior with Screenshots
- Upload operations fail for EU region buckets
- The S3 client attempts to connect to https://{account_id}.r2.cloudflarestorage.com (default endpoint)
- Connection fails or returns authentication/access errors because the bucket exists on the EU endpoint
- Error messages in console logs show S3/R2 operation failures
- Users see upload error messages or timeouts
- Files are not uploaded to R2
馃捇 Operating system
Linux
馃 Node Version
22.20-alpine
馃搩 Provide any additional context for the Bug.
No response
馃憖 Have you spent some time to check if this bug has been raised before?
Are you willing to submit PR?
Yes I am willing to submit a PR!
馃摐 Description
The application uses Cloudflare R2 for file uploads via the AWS S3 SDK. The R2 client is initialized with a hardcoded endpoint URL that only works for US/default region buckets. When a bucket is created in the EU region, all upload operations fail because the endpoint URL format is different.
Technical Details :
馃憻 Reproduction steps
NoSuchBucket: The specified bucket does not exist.馃憤 Expected behavior
馃憥 Actual Behavior with Screenshots
馃捇 Operating system
Linux
馃 Node Version
22.20-alpine
馃搩 Provide any additional context for the Bug.
No response
馃憖 Have you spent some time to check if this bug has been raised before?
Are you willing to submit PR?
Yes I am willing to submit a PR!