import type { NextConfig } from "next";

const nextConfig: NextConfig = {
    /* config options here */
    reactStrictMode: false,
	productionBrowserSourceMaps: true,

	// CI build does not block on lint; run `npm run lint` as a separate stage if needed.
	eslint: {
		ignoreDuringBuilds: true
	},

	images: {
        remotePatterns: [
            {
                protocol: "https",
                hostname: "localhost",
                port: "4000",
                pathname: "/uploads/**"
            },
			{
				protocol: "https",
				hostname: "api.antooza.com",
				pathname: "/uploads/**"
			},
			{
				protocol: "https",
				hostname: "dev-api.antooza.com",
				pathname: "/uploads/**"
			},
			{
				protocol: "https",
				hostname: "resource.antooza.com",
				pathname: "/uploads/**"
			},
			{
				protocol: "https",
				hostname: "dev-resource.antooza.com",
				pathname: "/uploads/**"
			},
			{
				protocol: "https",
				hostname: "img.youtube.com"
			},
			{
				protocol: "https",
				hostname: "yt3.ggpht.com"
			},
			{
				protocol: "https",
				hostname: "yt3.googleusercontent.com"
			}
        ],
    },

	experimental: {
		authInterrupts: true, // 인증 중단 기능 활성화

		serverActions: {
			bodySizeLimit: '200mb' // 최대 요청 본문 크기 설정
		}
	},

	// 배포 최적화
	output: 'standalone',

	// SVG 사용하기 위한 추가
	webpack(config) {
		config.module.rules.push({
			test: /\.svg$/,
			use: ['@svgr/webpack'],
		});
		return config;
	},

	async rewrites() {
		return [
			{
				source: '/uploads/:path*',
				destination: '/api/uploads/:path*'
			}
		];
	},

	async redirects() {
		return [
			{
				source: '/docs/privacy',
				destination: '/docs/privacy-policy',
				permanent: true
			},
			{
				source: '/docs/terms',
				destination: '/docs/terms-of-service',
				permanent: true
			}
		];
	}
};

export default nextConfig;
