Files
ember-market-frontend/next.config.mjs
NotII 5ce716d2ab Refactor docs structure and update API env config
Moved documentation files into a new docs/ directory and added a documentation index (docs/README.md). Updated the main README with improved project and documentation details. Set explicit API environment variables in Dockerfile for production. Enhanced next.config.mjs with improved API_BASE_URL handling and logging for better deployment clarity.
2025-09-01 16:48:42 +01:00

68 lines
1.7 KiB
JavaScript

import bundleAnalyzer from '@next/bundle-analyzer';
const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true' });
/** @type {import('next').NextConfig} */
const baseConfig = {
output: 'standalone',
reactStrictMode: false,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "api.telegram.org",
},
{
protocol: "https",
hostname: "telegram.org",
},
// Backend API hostname configured via environment variable
...(process.env.API_HOSTNAME ? [{
protocol: "https",
hostname: process.env.API_HOSTNAME,
}] : []),
],
},
async rewrites() {
const apiBaseUrl = process.env.API_BASE_URL;
// Ensure API_BASE_URL is valid to prevent 500 errors
if (!apiBaseUrl || apiBaseUrl === 'undefined') {
console.warn('⚠️ API_BASE_URL not set! Set it to your backend domain');
console.warn('⚠️ Using localhost fallback - this will fail in production!');
return [
{
source: '/api/:path*',
destination: 'http://localhost:3001/api/:path*',
},
];
}
console.log(`🔗 API rewrites pointing to: ${apiBaseUrl}`);
return [
{
source: '/api/:path*',
destination: `${apiBaseUrl}/api/:path*`,
},
];
},
experimental: {
// serverExternalPackages has been deprecated in Next.js 15
},
onDemandEntries: {
maxInactiveAge: 15 * 1000,
pagesBufferLength: 2,
},
productionBrowserSourceMaps: false,
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
};
const nextConfig = withBundleAnalyzer(baseConfig);
export default nextConfig;