/** @type {import('next').NextConfig} */ // v2 const nextConfig = { skipTrailingSlashRedirect: true, experimental: { proxyTimeout: 120000, // 2 minutes for long-running workout generation }, images: { remotePatterns: [ { protocol: "http", hostname: "localhost", port: "8000", }, { protocol: "http", hostname: "0.0.0.0", port: "8000", }, ], }, async rewrites() { const djangoUrl = process.env.DJANGO_INTERNAL_URL || "http://localhost:8000"; // Helper: for each Django prefix, create two rewrites: // 1. with trailing slash preserved // 2. without trailing slash → add it (Django requires trailing slashes) const djangoPrefixes = [ "media", "registered_user", "exercise", "muscle", "equipment", "workout", "generator", "videos", "admin", ]; return djangoPrefixes.flatMap((prefix) => [ { source: `/${prefix}/:path*/`, destination: `${djangoUrl}/${prefix}/:path*/`, }, { source: `/${prefix}/:path*`, destination: `${djangoUrl}/${prefix}/:path*/`, }, ]); }, }; export default nextConfig;