Files
pawol.nu/next.config.js
T

77 lines
1.9 KiB
JavaScript

const withPWA = require('next-pwa')({
disable: process.env.NODE_ENV !== 'production',
dest: 'public',
register: 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
}
async function headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin'
},
{
key: 'Cross-Origin-Resource-Policy',
value: 'same-site'
},
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin'
},
{
key: 'Permissions-Policy',
value: 'accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()'
}
]
}
]
}
module.exports = (withPWA({
turbopack: {},
poweredByHeader: false,
images: {
remotePatterns: buildRemotePatterns()
},
headers
}))