diff --git a/next.config.ts b/next.config.ts index f2fec53..614ddfb 100755 --- a/next.config.ts +++ b/next.config.ts @@ -2,8 +2,11 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { output: "standalone", + poweredByHeader: false, + compress: true, images: { formats: ["image/avif", "image/webp"], + minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days }, async headers() { return [ @@ -20,6 +23,30 @@ const nextConfig: NextConfig = { { key: "X-DNS-Prefetch-Control", value: "on" }, ], }, + { + // Long cache for static images served from /public/images. + source: "/images/(.*)", + headers: [ + { + key: "Cache-Control", + value: "public, max-age=31536000, immutable", + }, + ], + }, + ]; + }, + async redirects() { + return [ + // Force apex hostname. The www host should be terminated upstream + // (Nginx Proxy Manager) and pointed at this app, OR redirected at the + // proxy. This Next-side redirect is a belt-and-braces fallback so that + // www → apex still happens if traffic reaches the app on the wrong host. + { + source: "/:path*", + has: [{ type: "host", value: "www.wilddragon.net" }], + destination: "https://wilddragon.net/:path*", + permanent: true, + }, ]; }, };