import type { NextConfig } from "next"; const nextConfig: NextConfig = { // Otimização de imagens images: { formats: ["image/webp", "image/avif"], deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840], imageSizes: [16, 32, 48, 64, 96, 128, 256, 384], minimumCacheTTL: 60, }, // Otimizações de performance experimental: { scrollRestoration: true, }, // Headers de cache e segurança async headers(): Promise< Array<{ source: string; headers: Array<{ key: string; value: string }> }> > { const securityHeaders = [ { key: "X-Frame-Options", value: "DENY", }, { key: "X-Content-Type-Options", value: "nosniff", }, { key: "Referrer-Policy", value: "strict-origin-when-cross-origin", }, { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()", }, ]; // HSTS apenas em produção com HTTPS if (process.env.NODE_ENV === "production") { securityHeaders.push({ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains; preload", }); } return [ { source: "/(.*)", headers: securityHeaders, }, { source: "/static/(.*)", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, { source: "/_next/image(.*)", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, { source: "/fonts/(.*)", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, { source: "/assets/(.*)", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, { source: "/logos/(.*)", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, ]; }, // Proxy reverso para bypass de adblockers async rewrites() { return [ // Rybbit Analytics { source: "/analytics/:match*", destination: "https://analytics.evandro.dev.br/:match*", }, // Google Analytics - Script principal (camuflado como lib de sistema) { source: "/sys/libs/vendor-utils.js", destination: "https://www.googletagmanager.com/gtag/js?id=G-QTT9QT0T3S", }, // Google Analytics - Endpoint de coleta (camuflado como API de vitals) // O gtag.js adiciona "/g/collect" automaticamente ao final da transport_url { source: "/sys/api/vitals/g/collect", destination: "https://www.google-analytics.com/g/collect", }, ]; }, // Compressão compress: true, }; export default nextConfig;