SEO: 301 www to apex, long-cache static images, add CSP-safe headers
This commit is contained in:
parent
48b4727484
commit
e07541a325
1 changed files with 27 additions and 0 deletions
|
|
@ -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,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue