Files
webb/next.config.mjs
T

47 lines
1.2 KiB
JavaScript
Raw Normal View History

import os from 'os';
function getLocalDevOrigins() {
const origins = ['192.168.1.32', 'localhost', '127.0.0.1'];
try {
const interfaces = os.networkInterfaces();
for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name] || []) {
if (!iface.internal && iface.family === 'IPv4') {
origins.push(iface.address);
}
}
}
} catch (e) {
// fallback gracefully
}
return Array.from(new Set(origins));
}
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
allowedDevOrigins: getLocalDevOrigins(),
images: {
unoptimized: true,
},
experimental: {
serverComponentsExternalPackages: ['sharp'],
},
async redirects() {
try {
const fs = await import('fs');
const path = await import('path');
const redirectsPath = path.join(process.cwd(), 'content', 'redirects.json');
if (fs.existsSync(redirectsPath)) {
const data = JSON.parse(fs.readFileSync(redirectsPath, 'utf8'));
return Array.isArray(data) ? data : [];
}
} catch (e) {
console.warn('Could not load redirects.json', e);
}
return [];
},
};
export default nextConfig;