Skip to content

Your favorite shift management application!

1.8 KB
Raw Blame
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";

const withNextIntl = createNextIntlPlugin("./lib/i18n.ts");

const nextConfig: NextConfig = {
  /* config options here */
  output: "standalone",

  // Extra hosts allowed to hit dev-only endpoints (e.g. HMR) besides localhost.
  // Needed for remote dev setups (VS Code Remote, port forwarding, LAN devices).
  ...(process.env.NODE_ENV !== "production" && process.env.DEV_ALLOWED_ORIGINS
    ? {
        allowedDevOrigins: process.env.DEV_ALLOWED_ORIGINS.split(",")
          .map((origin) => origin.trim())
          .filter(Boolean),
      }
    : {}),

  // No <Image> anywhere: avatars are plain <img>. Declaring that lets the
  // trace exclude below drop sharp (~46 MB) without breaking a reachable path.
  images: { unoptimized: true },
  outputFileTracingExcludes: {
    "next-server": ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"],
  },

  // Build optimizations
  compiler: {
    removeConsole: process.env.NODE_ENV === "production"
      ? { exclude: ["error", "warn"] }
      : false,
  },

  async headers() {
    // Content-Security-Policy is set per-request in proxy.ts instead, since it
    // carries a fresh nonce for every response.
    return [
      {
        source: "/(.*)",
        headers: [
          {
            key: "X-Content-Type-Options",
            value: "nosniff",
          },
          {
            key: "X-Frame-Options",
            value: "DENY",
          },
          {
            key: "Referrer-Policy",
            value: "strict-origin-when-cross-origin",
          },
          {
            key: "X-XSS-Protection",
            value: "1; mode=block",
          },
        ],
      },
    ];
  },
};

export default withNextIntl(nextConfig);