diff --git a/src/config-manager.ts b/src/config-manager.ts index fb9d1c7..7d98100 100644 --- a/src/config-manager.ts +++ b/src/config-manager.ts @@ -56,7 +56,9 @@ export const config: Config = { s3: { endpoint: process.env.PN_ACT_CONFIG_S3_ENDPOINT || '', key: process.env.PN_ACT_CONFIG_S3_ACCESS_KEY || '', - secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '' + secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '', + region: process.env.PN_ACT_CONFIG_S3_REGION || '', + forcePathStyle: process.env.PN_ACT_CONFIG_S3_FORCE_PATH_STYLE === 'true' }, hcaptcha: { secret: process.env.PN_ACT_CONFIG_HCAPTCHA_SECRET || '' @@ -195,6 +197,11 @@ if (!config.s3.secret) { disabledFeatures.s3 = true; } +if (!config.s3.region) { + LOG_WARN('Failed to find S3 region config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_REGION environment variable'); + disabledFeatures.s3 = true; +} + if (!config.server_environment) { LOG_WARN('Failed to find server environment. To change the environment, set the PN_ACT_CONFIG_SERVER_ENVIRONMENT environment variable. Defaulting to prod'); config.server_environment = 'prod'; diff --git a/src/types/common/config.ts b/src/types/common/config.ts index 5585280..3554c56 100644 --- a/src/types/common/config.ts +++ b/src/types/common/config.ts @@ -30,6 +30,8 @@ export interface Config { endpoint: string; key: string; secret: string; + region: string; + forcePathStyle: boolean; }; hcaptcha: { secret: string; diff --git a/src/util.ts b/src/util.ts index 8df0490..753bfb3 100644 --- a/src/util.ts +++ b/src/util.ts @@ -20,6 +20,8 @@ let s3: S3; if (!disabledFeatures.s3) { s3 = new S3({ endpoint: config.s3.endpoint, + forcePathStyle: config.s3.forcePathStyle, + region: config.s3.region, credentials: { accessKeyId: config.s3.key,