dimah-s3v1.5.5
Providers

MinIO

Self-hosted S3 storage with path-style addressing and server CORS.

MinIO is a lightweight, self-hosted S3-compatible object store.

Configuration

Set forcePathStyle: true on the S3Client so object URLs format as http://host:9000/bucket/key:

lib/s3.ts
import { S3Client } from "@aws-sdk/client-s3";
import { dimahS3, route } from "@dimah-s3/server";

export const awsS3 = new S3Client({
  region: "us-east-1",
  endpoint: process.env.S3_ENDPOINT || "http://localhost:9000",
  forcePathStyle: true, // Required for MinIO
  credentials: {
    accessKeyId: process.env.S3_ACCESS_KEY_ID || "minioadmin",
    secretAccessKey: process.env.S3_SECRET_ACCESS_KEY || "minioadmin",
  },
});

export const s3 = dimahS3({
  client: awsS3,
  bucket: "my-bucket",
  routes: {
    avatar: route({
      upload: {
        fileTypes: ["image/*"],
        maxFileSize: 2 * 1024 * 1024,
      },
    }),
  },
});

MinIO CORS configuration

Set the MINIO_API_CORS_ALLOW_ORIGIN environment variable on your MinIO server:

MINIO_API_CORS_ALLOW_ORIGIN=https://your-app.example

Frequently asked questions

On this page