import type { NextConfig } from "next"; const nextConfig: NextConfig = { // não anuncia "X-Powered-By: Next.js" em cada resposta poweredByHeader: false, // 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, }, turbopack: { root: process.cwd(), }, async redirects() { return [ { source: "/servicos/sob-medida", destination: "/servicos/engenharia-de-software", permanent: true, }, ]; }, async headers(): Promise< Array<{ source: string; headers: Array<{ key: string; value: string }> }> > { const scriptSources = [ "'self'", "'unsafe-inline'", ...(process.env.NODE_ENV === "production" ? [] : ["'unsafe-eval'"]), "https://www.googletagmanager.com", ].join(" "); const contentSecurityPolicy = [ "default-src 'self'", `script-src ${scriptSources}`, "connect-src 'self' https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com", "img-src 'self' data: blob: https://*.google-analytics.com https://www.googletagmanager.com", "style-src 'self' 'unsafe-inline'", "font-src 'self' data:", "frame-ancestors 'none'", "object-src 'none'", "base-uri 'self'", "form-action 'self'", ].join("; "); 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=()", }, { key: "Content-Security-Policy-Report-Only", value: contentSecurityPolicy, }, ]; if (process.env.NODE_ENV === "production") { securityHeaders.push({ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains; preload", }); } return [ { source: "/(.*)", headers: securityHeaders, }, { // vídeos da vitrine (46 MB): sem o hash no nome, um dia de cache e revalidação em segundo plano na semana seguinte source: "/videos/:path*", headers: [ { key: "Cache-Control", value: "public, max-age=86400, stale-while-revalidate=604800", }, ], }, ]; }, // Compressão compress: true, }; export default nextConfig;