Skip to content

Commit 7868c8c

Browse files
Added S3_FORCE_PATH_STYLE environment variable support for AWS S3 client configuration to ensure compatibility with custom S3 endpoints and path-style URLs. This change sets the forcePathStyle option based on the environment variable, defaulting to false if not provided. (#3315)
Co-authored-by: Thiago Assis <[email protected]>
1 parent 14b7148 commit 7868c8c

File tree

6 files changed

+9
-1
lines changed

6 files changed

+9
-1
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Flowise support different environment variables to configure your instance. You
157157
| S3_STORAGE_SECRET_ACCESS_KEY | AWS Secret Key | String | |
158158
| S3_STORAGE_REGION | Region for S3 bucket | String | |
159159
| S3_ENDPOINT_URL | Custom Endpoint for S3 | String | |
160+
| S3_FORCE_PATH_STYLE | Set this to true to force the request to use path-style addressing | Boolean | false |
160161
| SHOW_COMMUNITY_NODES | Show nodes created by community | Boolean | |
161162

162163
You can also specify the env variables when using `npx`. For example:

docker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ BLOB_STORAGE_PATH=/root/.flowise/storage
4848
# S3_STORAGE_SECRET_ACCESS_KEY=<your-secret-key>
4949
# S3_STORAGE_REGION=us-west-2
5050
# S3_ENDPOINT_URL=<custom-s3-endpoint-url>
51+
# S3_FORCE_PATH_STYLE=false
5152

5253
# APIKEY_STORAGE_TYPE=json (json | db)
5354
# SHOW_COMMUNITY_NODES=true

i18n/CONTRIBUTING-ZH.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Flowise 支持不同的环境变量来配置您的实例。您可以在 `package
150150
| S3_STORAGE_SECRET_ACCESS_KEY | AWS 密钥 (Secret Key) | 字符串 | |
151151
| S3_STORAGE_REGION | S3 存储地区 | 字符串 | |
152152
| S3_ENDPOINT_URL | S3 端点 URL | 字符串 | |
153+
| S3_FORCE_PATH_STYLE | 将其设置为 true 以强制请求使用路径样式寻址 | Boolean | false |
153154
| SHOW_COMMUNITY_NODES | 显示由社区创建的节点 | 布尔值 | |
154155

155156
您也可以在使用 `npx` 时指定环境变量。例如:

packages/components/src/storageUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export const getS3Config = () => {
331331
const region = process.env.S3_STORAGE_REGION
332332
const Bucket = process.env.S3_STORAGE_BUCKET_NAME
333333
const customURL = process.env.S3_ENDPOINT_URL
334+
const forcePathStyle = process.env.S3_FORCE_PATH_STYLE === 'true' ? true : false
334335

335336
if (!region || !Bucket) {
336337
throw new Error('S3 storage configuration is missing')
@@ -347,7 +348,8 @@ export const getS3Config = () => {
347348
const s3Client = new S3Client({
348349
credentials,
349350
region,
350-
endpoint: customURL
351+
endpoint: customURL,
352+
forcePathStyle: forcePathStyle
351353
})
352354
return { s3Client, Bucket }
353355
}

packages/server/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ PORT=3000
4848
# S3_STORAGE_SECRET_ACCESS_KEY=<your-secret-key>
4949
# S3_STORAGE_REGION=us-west-2
5050
# S3_ENDPOINT_URL=<custom-s3-endpoint-url>
51+
# S3_FORCE_PATH_STYLE=false
5152

5253
# APIKEY_STORAGE_TYPE=json (json | db)
5354
# SHOW_COMMUNITY_NODES=true

packages/server/src/commands/start.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class Start extends Command {
5555
S3_STORAGE_SECRET_ACCESS_KEY: Flags.string(),
5656
S3_STORAGE_REGION: Flags.string(),
5757
S3_ENDPOINT_URL: Flags.string(),
58+
S3_FORCE_PATH_STYLE: Flags.string(),
5859
SHOW_COMMUNITY_NODES: Flags.string()
5960
}
6061

@@ -152,6 +153,7 @@ export default class Start extends Command {
152153
if (flags.S3_STORAGE_SECRET_ACCESS_KEY) process.env.S3_STORAGE_SECRET_ACCESS_KEY = flags.S3_STORAGE_SECRET_ACCESS_KEY
153154
if (flags.S3_STORAGE_REGION) process.env.S3_STORAGE_REGION = flags.S3_STORAGE_REGION
154155
if (flags.S3_ENDPOINT_URL) process.env.S3_ENDPOINT_URL = flags.S3_ENDPOINT_URL
156+
if (flags.S3_FORCE_PATH_STYLE) process.env.S3_FORCE_PATH_STYLE = flags.S3_FORCE_PATH_STYLE
155157

156158
await (async () => {
157159
try {

0 commit comments

Comments
 (0)