From c71347aeb93e6ea68db49c145e964e1016958a7d Mon Sep 17 00:00:00 2001 From: Valentin Lestoille Date: Fri, 22 Mar 2024 15:46:22 +0100 Subject: [PATCH] S3Client: Add forcePathStyle --- .env.example | 2 ++ docker/README.md | 1 + docker/production/compose.yml | 1 + packages/lib/universal/upload/server-actions.ts | 1 + packages/tsconfig/process-env.d.ts | 1 + render.yaml | 2 ++ turbo.json | 1 + 7 files changed, 9 insertions(+) diff --git a/.env.example b/.env.example index 1f2df8550..343ae91c9 100644 --- a/.env.example +++ b/.env.example @@ -55,6 +55,8 @@ NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH= NEXT_PUBLIC_UPLOAD_TRANSPORT="database" # OPTIONAL: Defines the endpoint to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. NEXT_PRIVATE_UPLOAD_ENDPOINT="http://127.0.0.1:9002" +# OPTIONAL: Defines the force path style to use for the S3 storage transport. Relevant when using third-party S3-compatible providers. +NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE="false" # OPTIONAL: Defines the region to use for the S3 storage transport. Defaults to us-east-1. NEXT_PRIVATE_UPLOAD_REGION="unknown" # REQUIRED: Defines the bucket to use for the S3 storage transport. diff --git a/docker/README.md b/docker/README.md index bda1638a2..2b0ce9953 100644 --- a/docker/README.md +++ b/docker/README.md @@ -115,6 +115,7 @@ Here's a markdown table documenting all the provided environment variables: | `NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH` | The path to the key file, default `/opt/documenso/cert.p12`. | | `NEXT_PUBLIC_UPLOAD_TRANSPORT` | The transport to use for file uploads (database or s3). | | `NEXT_PRIVATE_UPLOAD_ENDPOINT` | The endpoint for the S3 storage transport (for third-party S3-compatible providers). | +| `NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE` | Whether to force path-style URLs for the S3 storage transport. | | `NEXT_PRIVATE_UPLOAD_REGION` | The region for the S3 storage transport (defaults to us-east-1). | | `NEXT_PRIVATE_UPLOAD_BUCKET` | The bucket to use for the S3 storage transport. | | `NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID` | The access key ID for the S3 storage transport. | diff --git a/docker/production/compose.yml b/docker/production/compose.yml index 02acc655d..bcbd9b857 100644 --- a/docker/production/compose.yml +++ b/docker/production/compose.yml @@ -34,6 +34,7 @@ services: - NEXT_PRIVATE_DIRECT_DATABASE_URL=${NEXT_PRIVATE_DIRECT_DATABASE_URL:-${NEXT_PRIVATE_DATABASE_URL}} - NEXT_PUBLIC_UPLOAD_TRANSPORT=${NEXT_PUBLIC_UPLOAD_TRANSPORT:-database} - NEXT_PRIVATE_UPLOAD_ENDPOINT=${NEXT_PRIVATE_UPLOAD_ENDPOINT} + - NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE=${NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE} - NEXT_PRIVATE_UPLOAD_REGION=${NEXT_PRIVATE_UPLOAD_REGION} - NEXT_PRIVATE_UPLOAD_BUCKET=${NEXT_PRIVATE_UPLOAD_BUCKET} - NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID=${NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID} diff --git a/packages/lib/universal/upload/server-actions.ts b/packages/lib/universal/upload/server-actions.ts index fd4bfc57a..609cfdff7 100644 --- a/packages/lib/universal/upload/server-actions.ts +++ b/packages/lib/universal/upload/server-actions.ts @@ -132,6 +132,7 @@ const getS3Client = () => { return new S3Client({ endpoint: process.env.NEXT_PRIVATE_UPLOAD_ENDPOINT || undefined, + forcePathStyle: process.env.NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE || 'false', region: process.env.NEXT_PRIVATE_UPLOAD_REGION || 'us-east-1', credentials: hasCredentials ? { diff --git a/packages/tsconfig/process-env.d.ts b/packages/tsconfig/process-env.d.ts index 1b9c577cf..761defd54 100644 --- a/packages/tsconfig/process-env.d.ts +++ b/packages/tsconfig/process-env.d.ts @@ -17,6 +17,7 @@ declare namespace NodeJS { NEXT_PUBLIC_UPLOAD_TRANSPORT?: 'database' | 's3'; NEXT_PRIVATE_UPLOAD_ENDPOINT?: string; + NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE?: string; NEXT_PRIVATE_UPLOAD_REGION?: string; NEXT_PRIVATE_UPLOAD_BUCKET?: string; NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID?: string; diff --git a/render.yaml b/render.yaml index 9fe1bd2e9..6416e9ffb 100644 --- a/render.yaml +++ b/render.yaml @@ -85,6 +85,8 @@ services: value: 'database' - key: NEXT_PRIVATE_UPLOAD_ENDPOINT sync: false + - key: NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE + sync: false - key: NEXT_PRIVATE_UPLOAD_REGION sync: false - key: NEXT_PRIVATE_UPLOAD_BUCKET diff --git a/turbo.json b/turbo.json index d17a09661..5e2ef340d 100644 --- a/turbo.json +++ b/turbo.json @@ -60,6 +60,7 @@ "NEXT_PRIVATE_GOOGLE_CLIENT_SECRET", "NEXT_PUBLIC_UPLOAD_TRANSPORT", "NEXT_PRIVATE_UPLOAD_ENDPOINT", + "NEXT_PRIVATE_UPLOAD_FORCE_PATH_STYLE", "NEXT_PRIVATE_UPLOAD_REGION", "NEXT_PRIVATE_UPLOAD_BUCKET", "NEXT_PRIVATE_UPLOAD_ACCESS_KEY_ID",