- Updated nest-cli.json to enable output directory deletion and refined TypeScript compiler options. - Modified package.json to improve development command for BFF with preserved watch output. - Adjusted tsconfig.json to extend from a higher-level configuration and removed unnecessary options. - Enhanced logging.module.ts to simplify logger configuration and improve log message formatting. - Updated next.config.mjs to manage server-only libraries and optimize Webpack configuration. - Refined error logging in various components for better clarity and consistency.
108 lines
2.9 KiB
JavaScript
108 lines
2.9 KiB
JavaScript
/* eslint-env node */
|
|
import path from "node:path";
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
// Enable standalone output only for production deployment
|
|
output: process.env.NODE_ENV === "production" ? "standalone" : undefined,
|
|
|
|
// Tell Next to NOT bundle these server-only libs
|
|
serverExternalPackages: [
|
|
"pino",
|
|
"pino-pretty",
|
|
"pino-abstract-transport",
|
|
"thread-stream",
|
|
"sonic-boom",
|
|
],
|
|
|
|
// Turbopack configuration (Next.js 15.5+)
|
|
turbopack: {
|
|
// Enable Turbopack optimizations
|
|
resolveAlias: {
|
|
// Path aliases for cleaner imports
|
|
"@": "./src",
|
|
},
|
|
},
|
|
|
|
// Environment variables validation
|
|
env: {
|
|
NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE,
|
|
NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME,
|
|
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION,
|
|
},
|
|
|
|
// Image optimization
|
|
images: {
|
|
remotePatterns: [
|
|
{
|
|
protocol: "https",
|
|
hostname: "**",
|
|
},
|
|
],
|
|
},
|
|
|
|
// Disable ESLint blocking during production builds to avoid CI/CD failures
|
|
eslint: {
|
|
ignoreDuringBuilds: true,
|
|
},
|
|
|
|
// Security headers
|
|
async headers() {
|
|
return [
|
|
{
|
|
// Apply security headers to all routes
|
|
source: "/(.*)",
|
|
headers: [
|
|
{
|
|
key: "X-Frame-Options",
|
|
value: "DENY",
|
|
},
|
|
{
|
|
key: "X-Content-Type-Options",
|
|
value: "nosniff",
|
|
},
|
|
{
|
|
key: "Referrer-Policy",
|
|
value: "strict-origin-when-cross-origin",
|
|
},
|
|
{
|
|
key: "X-XSS-Protection",
|
|
value: "1; mode=block",
|
|
},
|
|
// Content Security Policy - development-friendly
|
|
{
|
|
key: "Content-Security-Policy",
|
|
value:
|
|
process.env.NODE_ENV === "development"
|
|
? "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https: http://localhost:* ws://localhost:*; frame-ancestors 'none';"
|
|
: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https:; frame-ancestors 'none';",
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
|
|
// Production optimizations
|
|
compiler: {
|
|
// Remove console.logs in production
|
|
removeConsole: process.env.NODE_ENV === "production",
|
|
},
|
|
|
|
// Webpack configuration for fallback compatibility
|
|
webpack: (config, { isServer }) => {
|
|
config.resolve.alias["@"] = path.resolve(process.cwd(), "src");
|
|
if (isServer) {
|
|
config.externals.push(
|
|
"pino",
|
|
"pino-pretty",
|
|
"pino-abstract-transport",
|
|
"thread-stream",
|
|
"sonic-boom",
|
|
);
|
|
}
|
|
return config;
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|