/** @type {import('next').NextConfig} */
import path from 'path';

const __dirname = path.resolve();
const adminDomain = process.env.ADMIN_DOMAIN || "http://localhost:9001";

const nextConfig = {
  transpilePackages: ['@workspace/ui', '@workspace/db'],
  output: 'standalone',
  outputFileTracingRoot: path.join(__dirname, '../../'),
  async rewrites() {
    return [
        {
            source: '/admin',
            destination: `${adminDomain}/admin`,
        },
        {
            source: '/admin/:path+',
            destination: `${adminDomain}/admin/:path+`,
        },
        {
            source: '/admin-static/:path+',
            destination: `${adminDomain}/admin-static/:path+`,
        }
    ];
}
};

export default nextConfig;
