/** @type {import('next').NextConfig} */
const nextConfig = {
  poweredByHeader: false,
  transpilePackages: [
    "@link-stack/leafcutter-ui",
    "@link-stack/opensearch-common",
    "@link-stack/ui",
    "@link-stack/bridge-common",
    "@link-stack/bridge-ui",
    "mui-chips-input",
  ],
  headers: async () => {
    return [
      {
        source: "/((?!zammad).*)",
        headers: [
          {
            key: "Strict-Transport-Security",
            value: "max-age=63072000; includeSubDomains; preload",
          },
          {
            key: "X-Frame-Options",
            value: "DENY",
          },
          {
            key: "X-Content-Type-Options",
            value: "nosniff",
          },
        ],
      },
    ];
  },
  rewrites: async () => {
    return {
      beforeFiles: [
        {
          source: "/api/v1/:path*",
          destination: `${process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080"}/api/v1/:path*`,
        },
        {
          source: "/ws",
          destination: `${process.env.ZAMMAD_URL ?? "http://zammad-nginx:8080"}/ws`,
        },
      ],
    };
  },
};

export default nextConfig;
