diff options
| author | Mert Demir <mertd@users.noreply.github.com> | 2024-02-01 07:00:19 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-31 17:00:19 -0500 |
| commit | 08d75fd75c063bd17d2471b263452b490910338b (patch) | |
| tree | 8374575ab7ad02327fa3a4fbfa5d04415d3944d6 /next.config.js | |
| parent | e6467b41fccefe1ceb39dd1ed6343290e152be85 (diff) | |
Support for additional S3 providers (#71)
* support for other s3 providers
* remove redundant route options
* use type safe env
* prettier
Diffstat (limited to 'next.config.js')
| -rw-r--r-- | next.config.js | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/next.config.js b/next.config.js index 6d6b0c3..89faa5d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,14 +1,27 @@ +/** + * Undefined entries are not supported. Push optional patterns to this array only if defined. + * @type {import('next/dist/shared/lib/image-config').RemotePattern} + */ +const remotePatterns = [] + +// S3 Storage +if (process.env.S3_UPLOAD_ENDPOINT) { + // custom endpoint for providers other than AWS + const url = new URL(process.env.S3_UPLOAD_ENDPOINT); + remotePatterns.push({ + hostname: url.hostname, + }) +} else if (process.env.S3_UPLOAD_BUCKET && process.env.S3_UPLOAD_REGION) { + // default provider + remotePatterns.push({ + hostname: `${process.env.S3_UPLOAD_BUCKET}.s3.${process.env.S3_UPLOAD_REGION}.amazonaws.com`, + }) +} + /** @type {import('next').NextConfig} */ const nextConfig = { images: { - remotePatterns: - process.env.S3_UPLOAD_BUCKET && process.env.S3_UPLOAD_REGION - ? [ - { - hostname: `${process.env.S3_UPLOAD_BUCKET}.s3.${process.env.S3_UPLOAD_REGION}.amazonaws.com`, - }, - ] - : [], + remotePatterns }, } |
