import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  // Emits a self-contained server bundle, which is what the Docker image copies.
  output: 'standalone',

  // Type and lint errors must fail the build rather than be waved through — a console
  // that dispatches grid actions is not a place for "we'll fix it later".
  typescript: { ignoreBuildErrors: false },
  eslint: { ignoreDuringBuilds: false },

  // Hide the framework banner; it tells an attacker what to look up and tells a user
  // nothing.
  poweredByHeader: false,

  experimental: {
    // Keeps the server bundle small by not tracing the whole workspace.
    optimizePackageImports: ['recharts'],
  },

  async headers() {
    return [
      {
        // Security headers are set in middleware for every request; these are the
        // static-asset caching rules, which middleware deliberately does not run for.
        source: '/:path*',
        headers: [{ key: 'X-Content-Type-Options', value: 'nosniff' }],
      },
    ]
  },
}

export default nextConfig
