Files
pragativeer-v2/next.config.ts

53 lines
1.9 KiB
TypeScript

import type { NextConfig } from "next";
// Backend URL used for the SERVER-SIDE /api rewrite. Must resolve on the
// Docker network, so it must NOT be a public origin (that would create a loop).
// Use BACKEND_INTERNAL_URL (set at container runtime) so client components can
// independently use NEXT_PUBLIC_API_URL (public origin, baked at build time).
const API_BASE =
process.env.BACKEND_INTERNAL_URL ||
process.env.NEXT_PUBLIC_API_URL ||
"http://backend:8000";
const nextConfig: NextConfig = {
output: "standalone",
// ── Performance: strip X-Powered-By header ──────────────────────────────
poweredByHeader: false,
// ── Performance: gzip compression handled by Next.js standalone server ──
compress: true,
// ── Compiler optimisations ───────────────────────────────────────────────
compiler: {
// Remove console.log statements from production builds
removeConsole: process.env.NODE_ENV === "production"
? { exclude: ["error", "warn"] }
: false,
},
// ── Tree-shake large packages (only import what is used) ─────────────────
// This tells Next.js to side-effect-free import specific packages,
// significantly reducing the bundle size for heavy libraries.
experimental: {
optimizePackageImports: [
"lucide-react",
"recharts",
"framer-motion",
"date-fns",
],
},
// ── API proxy rewrites ───────────────────────────────────────────────────
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${API_BASE}/api/:path*`,
},
];
},
};
export default nextConfig;