/** @type {import('next').NextConfig} */
const websiteUrl = process.env.NODE_ENV === 'production' ? "https://encoach.com" : "http://localhost:3000";
const nextConfig = {
	reactStrictMode: false,
	output: "standalone",
	async headers() {
		return [
			{
				source: "/api/packages",
				headers: [
					{key: "Access-Control-Allow-Credentials", value: "false"},
					{key: "Access-Control-Allow-Origin", value: websiteUrl},
					{
						key: "Access-Control-Allow-Methods",
						value: "GET",
					},
					{
						key: "Access-Control-Allow-Headers",
						value: "Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date",
					},
				],
			},
			{
				source: "/api/tickets",
				headers: [
					{key: "Access-Control-Allow-Credentials", value: "false"},
					{key: "Access-Control-Allow-Origin", value: websiteUrl},
					{
						key: "Access-Control-Allow-Methods",
						value: "POST,OPTIONS",
					},
					{
						key: "Access-Control-Allow-Headers",
						value: "Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date",
					},
				],
			},
			{
				source: "/api/users/agents",
				headers: [
					{key: "Access-Control-Allow-Credentials", value: "false"},
					{key: "Access-Control-Allow-Origin", value: websiteUrl},
					{
						key: "Access-Control-Allow-Methods",
						value: "POST,OPTIONS",
					},
					{
						key: "Access-Control-Allow-Headers",
						value: "Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date",
					},
				],
			},
		];
	},
};

module.exports = nextConfig;
