fix: allow custom S3 enpoint via ENV variable#17
fix: allow custom S3 enpoint via ENV variable#17valtlfelipe wants to merge 1 commit intozmeyer44:mainfrom
Conversation
|
@valtlfelipe is attempting to deploy a commit to the Zach's Projects Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryAdds support for S3-compatible storage services by reading a custom endpoint from Confidence Score: 5/5Safe to merge — the core change is correct and functional for S3-compatible services All findings are P2 style suggestions. The forcePathStyle logic is correct for S3-compatible services and the trailing-slash edge case is an uncommon misconfiguration. packages/storage/src/s3.ts — minor trailing-slash edge case in URL construction Important Files Changed
Sequence DiagramsequenceDiagram
participant App
participant S3StorageAdapter
participant S3Client
participant Storage as Storage (AWS S3 or Compatible)
App->>S3StorageAdapter: upload(path, data, contentType)
Note over S3StorageAdapter: Uses endpoint from AWS_ENDPOINT_URL (if set)
S3StorageAdapter->>S3Client: PutObjectCommand(Bucket, Key, Body)
alt Custom endpoint set
S3Client->>Storage: PUT {endpoint}/{bucket}/{key} (path-style)
else AWS S3
S3Client->>Storage: PUT https://{bucket}.s3.{region}.amazonaws.com/{key} (virtual-hosted)
end
Storage-->>S3Client: 200 OK
S3Client-->>S3StorageAdapter: success
alt Custom endpoint set
S3StorageAdapter-->>App: url = {endpoint}/{bucket}/{path}
else AWS S3
S3StorageAdapter-->>App: url = https://{bucket}.s3.{region}.amazonaws.com/{path}
end
Reviews (1): Last reviewed commit: "fix: allow custom S3 enpoint via ENV var..." | Re-trigger Greptile |
| const baseURL = this.endpoint ? `${this.endpoint}/${this.bucket}` : | ||
| `https://${this.bucket}.s3.${this.region}.amazonaws.com`; |
There was a problem hiding this comment.
Trailing slash in endpoint URL
If AWS_ENDPOINT_URL is set with a trailing slash (e.g. https://minio.example.com/), the constructed object URL becomes https://minio.example.com//bucket/path, which will produce broken object links. Consider stripping the trailing slash on construction.
| const baseURL = this.endpoint ? `${this.endpoint}/${this.bucket}` : | |
| `https://${this.bucket}.s3.${this.region}.amazonaws.com`; | |
| const baseURL = this.endpoint ? `${this.endpoint.replace(/\/$/, '')}/${this.bucket}` : | |
| `https://${this.bucket}.s3.${this.region}.amazonaws.com`; |
Allow custom S3 enpoint via ENV variable For S3-compatible services. For custom s3 we should use virtual-hosted–style URLs.
Tested and validated on railway.
Here is the templatwe by the way: https://railway.com/deploy/locker-1?referralCode=ca9X8b&utm_medium=integration&utm_source=template&utm_campaign=generic
Can I add the button to the readme?