const dotenv = require("dotenv"); const dotenvExpand = require("dotenv-expand"); dotenvExpand.expand(dotenv.config({ path: "../.env", quiet: true })); const { withSentryConfig } = require("@sentry/nextjs"); /** @type {import('next').NextConfig} */ // HTTP Security Headers const nextConfig = { poweredByHeader: false, // Use standalone only in production deployments, not for CI/testing ...(process.env.NODE_ENV === "production" && !process.env.CI && { output: "standalone", outputFileTracingRoot: __dirname, }), // React Compiler is now stable in Next.js 16 reactCompiler: true, turbopack: { root: __dirname, }, async headers() { const headers = [ { key: "X-Content-Type-Options", value: "nosniff", }, { key: "Referrer-Policy", value: "strict-origin-when-cross-origin", }, ]; return [ { source: "/(.*)", headers, }, ]; }, }; // Sentry configuration options const sentryWebpackPluginOptions = { org: process.env.SENTRY_ORG, project: process.env.SENTRY_PROJECT, authToken: process.env.SENTRY_AUTH_TOKEN, silent: true, // Suppresses all logs hideSourceMaps: true, // Hides source maps from generated client bundles disableLogger: true, // Automatically tree-shake Sentry logger statements to reduce bundle size widenClientFileUpload: true, // Upload a larger set of source maps for prettier stack traces }; // Export with Sentry only if configuration is available const hasSentryBuildCredentials = Boolean( process.env.SENTRY_AUTH_TOKEN && process.env.SENTRY_ORG && process.env.SENTRY_PROJECT, ); module.exports = hasSentryBuildCredentials ? withSentryConfig(nextConfig, sentryWebpackPluginOptions) : nextConfig;