import type { NextConfig } from "next";
import path from "node:path";

const isLocalWorktree = __dirname.includes(`${path.sep}.worktrees${path.sep}`);
const projectRoot = isLocalWorktree ? path.resolve(__dirname, "../..") : __dirname;

const nextConfig: NextConfig = {
  // Each blue/green release is built beneath .releases. Keep Next's file trace
  // inside that exact release instead of inferring the parent app directory.
  outputFileTracingRoot: projectRoot,
  // Local worktrees share the repository-level node_modules junction. Turbopack
  // must use their common parent as its filesystem root to resolve it safely.
  turbopack: isLocalWorktree
    ? { root: projectRoot }
    : undefined,
  // Proxy buffers request bodies before route handlers see them. Its 10 MiB
  // default truncates valid 25/40 MiB regular-attachment compose requests.
  // Match the compose route's explicit 64 MiB request cap.
  experimental: {
    proxyClientMaxBodySize: 64 * 1024 * 1024,
  },
  async redirects() {
    return [
      {
        source: "/blog/solo-business-client-onboarding-checklist",
        destination: "/blog/solo-business-customer-onboarding-checklist",
        permanent: true,
      },
    ];
  },
};

export default nextConfig;
