fix(storage): strip http/https scheme from MinIO endpoint env vars

This commit is contained in:
Admin
2026-03-14 15:19:02 +05:00
parent 7413313100
commit bceb6f2cbd

View File

@@ -37,6 +37,13 @@ type MinioClient struct {
// NewMinioClient creates a connected MinIO client and ensures the required
// buckets exist.
func NewMinioClient(ctx context.Context, cfg MinioConfig) (*MinioClient, error) {
// minio-go expects a bare "host:port" endpoint — strip any scheme prefix that
// callers may accidentally include (e.g. "https://minio.example.com").
cfg.Endpoint = strings.TrimPrefix(strings.TrimPrefix(cfg.Endpoint, "https://"), "http://")
if cfg.PublicEndpoint != "" {
cfg.PublicEndpoint = strings.TrimPrefix(strings.TrimPrefix(cfg.PublicEndpoint, "https://"), "http://")
}
c, err := minio.New(cfg.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""),
Secure: cfg.UseSSL,