/** @type {import('next').NextConfig} */
const nextConfig = {
	// Entwicklungsumgebung - weniger restriktive CORS
	async headers() {
		return [
			{
				source: "/:path*",
				headers: [
					{
						key: "Access-Control-Allow-Origin",
						value: "*",
					},
					{
						key: "Access-Control-Allow-Methods",
						value: "GET, POST, PUT, DELETE, OPTIONS",
					},
					{
						key: "Access-Control-Allow-Headers",
						value: "Content-Type, Authorization",
					},
				],
			},
		];
	},
	// Rewrites für Backend-API-Aufrufe zum Raspberry Pi
	async rewrites() {
		return [
			{
				source: '/api/backend/:path*',
				destination: 'https://192.168.0.105:5000/api/:path*',
			},
			// Direkter Proxy für Health-Checks
			{
				source: '/backend-health',
				destination: 'https://192.168.0.105:5000/health',
			},
		];
	},
	// Entwicklungseinstellungen
	experimental: {
		serverComponentsExternalPackages: [],
	},
	// Logging für Entwicklung
	logging: {
		fetches: {
			fullUrl: true,
		},
	},
};

export default nextConfig;
