import type { NextConfig } from "next";

import { parseAllowedDevOrigins } from "./src/lib/next-dev-origins";

const allowedDevOrigins = parseAllowedDevOrigins(process.env.ALLOWED_DEV_ORIGINS);

const nextConfig: NextConfig = {
  /* config options here */
  ...(allowedDevOrigins.length > 0 ? { allowedDevOrigins } : {}),
  reactCompiler: true,
  async redirects() {
    return [
      {
        source: "/admin/service-desk",
        destination: "/admin",
        permanent: true,
      },
      {
        source: "/admin/menu-permissions",
        destination: "/admin",
        permanent: true,
      },
    ];
  },
};

export default nextConfig;
