import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // AGENTS.md in this repo is hand-maintained; don't let Next.js regenerate it.
  agentRules: false,
  // `experimental.optimizeCss` (critical-CSS inlining via `beasties`) was
  // tried here but is a webpack-only feature (wired through
  // `next/dist/build/webpack-config.js`) — this project builds with
  // Turbopack, so it was a silent no-op (confirmed: zero effect on the
  // built HTML's `<link rel="stylesheet">` tags). Removed rather than left
  // in as dead config.
  // `public/` assets (icons, local images, fonts, videos — the app's own
  // real static files, not CMS-hosted content) get no special caching from
  // Next.js by default, unlike `/_next/static/*`: every repeat visit
  // re-requests them with just `Cache-Control: public, max-age=0` (a
  // conditional ETag revalidation, not an actual cached hit). Confirmed via
  // Lighthouse: ~1MB of repeat-visit transfer across this app's own
  // `/images/*` files alone. These aren't content-hashed filenames, so a
  // long max-age means a changed asset needs a filename change (or a cache
  // purge) to show up for returning visitors — an accepted tradeoff for
  // genuinely static files like these, not CMS content, which this doesn't
  // touch (that's served by the separate Joomla origin, outside this app's
  // control either way).
  allowedDevOrigins: [
    "172.23.17.13",
    "172.23.17.13:3000",
    "localhost",
    "localhost:3000",
    "localhost:3001",
  ],
  images: {
    remotePatterns: [
      { protocol: "http", hostname: "172.23.17.13" },
      { protocol: "https", hostname: "172.23.17.13" },
      { protocol: "http", hostname: "localhost" },
      { protocol: "https", hostname: "localhost" },
      { protocol: "https", hostname: "www.globalassignmenthelp.com" },
    ],
  },
  async headers() {
    const oneYear = "public, max-age=31536000, immutable";
    return [
      { source: "/images/:path*", headers: [{ key: "Cache-Control", value: oneYear }] },
      { source: "/icons/:path*", headers: [{ key: "Cache-Control", value: oneYear }] },
      { source: "/fonts/:path*", headers: [{ key: "Cache-Control", value: oneYear }] },
      { source: "/videos/:path*", headers: [{ key: "Cache-Control", value: oneYear }] },
      {
        // `app/page.tsx`'s deferred `home-page.css` (served from here instead
        // of a normal Next.js CSS import, specifically so it isn't
        // render-blocking — see that file's own comment) is just as static as
        // the asset types above, same tradeoff.
        source: "/css/:path*",
        headers: [{ key: "Cache-Control", value: oneYear }],
      },
    ];
  },
};

export default nextConfig;
