feat: parse image domains from NEXT_PUBLIC_DOMAINS_IMAGE
This commit is contained in:
+17
-24
@@ -5,6 +5,22 @@ const withPWA = require('next-pwa')({
|
|||||||
skipWaiting: true
|
skipWaiting: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function buildRemotePatterns() {
|
||||||
|
const raw = process.env.NEXT_PUBLIC_DOMAINS_IMAGE || ''
|
||||||
|
const patterns = raw.split(' ').filter(Boolean).map(entry => {
|
||||||
|
const [hostname, port] = entry.split(':')
|
||||||
|
const isLocal = hostname === 'localhost' || hostname === '127.0.0.1'
|
||||||
|
const pattern = {protocol: isLocal ? 'http' : 'https', hostname, pathname: '/uploads/**'}
|
||||||
|
if (port) pattern.port = port
|
||||||
|
return pattern
|
||||||
|
})
|
||||||
|
if (!raw.includes('localhost'))
|
||||||
|
patterns.push({protocol: 'http', hostname: 'localhost', port: '1337', pathname: '/uploads/**'})
|
||||||
|
if (!raw.includes('127.0.0.1'))
|
||||||
|
patterns.push({protocol: 'http', hostname: '127.0.0.1', port: '1337', pathname: '/uploads/**'})
|
||||||
|
return patterns
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = (withPWA({
|
module.exports = (withPWA({
|
||||||
turbopack: {},
|
turbopack: {},
|
||||||
webpack: config => {
|
webpack: config => {
|
||||||
@@ -16,29 +32,6 @@ module.exports = (withPWA({
|
|||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: buildRemotePatterns()
|
||||||
{
|
|
||||||
protocol: 'https',
|
|
||||||
hostname: 'api.pawol.nu',
|
|
||||||
pathname: '/uploads/**',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
protocol: 'https',
|
|
||||||
hostname: 'pawol.nu',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
protocol: 'http',
|
|
||||||
hostname: '127.0.0.1',
|
|
||||||
port: '1337',
|
|
||||||
pathname: '/uploads/**',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
protocol: 'http',
|
|
||||||
hostname: 'localhost',
|
|
||||||
port: '1337',
|
|
||||||
pathname: '/uploads/**',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user