-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
status: needs-triagePossible bug which hasn't been reproduced yetPossible bug which hasn't been reproduced yet
Description
Describe the Bug
Description
When using two s3Storage
plugin instances with different endpoints (e.g., AWS S3 and Cloudflare R2), the second plugin's endpoint configuration overwrites the first plugin's configuration, causing requests to use mixed endpoints.
Link to the code that reproduces this issue
private
Reproduction Steps
Configuration:
import { s3Storage } from '@payloadcms/storage-s3'
export default buildConfig({
plugins: [
// Plugin 1: AWS S3
s3Storage({
bucket: 'my-s3-bucket',
collections: {
fileupload: { /* ... */ },
postmedia: { /* ... */ },
},
config: {
credentials: { /* S3 credentials */ },
endpoint: 'https://s3.us-east-1.amazonaws.com',
region: 'us-east-1',
forcePathStyle: true,
},
}),
// Plugin 2: Cloudflare R2
s3Storage({
bucket: 'my-r2-bucket',
collections: {
media: { /* ... */ },
},
config: {
credentials: { /* R2 credentials */ },
endpoint: 'https://account-id.r2.cloudflarestorage.com',
region: 'auto',
forcePathStyle: true,
},
}),
],
})
Steps:
- Configure two
s3Storage
plugins as shown above - Upload a file to the
fileupload
collection (first plugin) - Observe the error
Expected Behavior
Each plugin instance should maintain its own isolated S3 client with independent endpoint configuration.
Actual Behavior
The upload request uses a mixed endpoint:
Host: my-s3-bucket.account-id.r2.cloudflarestorage.com
Error received:
ERROR: Access Denied
httpStatusCode: 403
servername: "my-s3-bucket.account-id.r2.cloudflarestorage.com"
The hostname incorrectly combines:
- Bucket name from the first plugin (
my-s3-bucket
) - Endpoint from the second plugin (
.r2.cloudflarestorage.com
)
Which area(s) are affected? (Select all that apply)
plugin: storage-*
Environment Info
### Environment
- **Payload Version:** 3.58.0
- **@payloadcms/storage-s3 Version:**3.58.0
- **Node Version:** v22.20.0
- **Package Manager:** pnpm
Metadata
Metadata
Assignees
Labels
status: needs-triagePossible bug which hasn't been reproduced yetPossible bug which hasn't been reproduced yet