import type { NextConfig } from "next"; import path from "path"; const nextConfig: NextConfig = { output: "standalone", allowedDevOrigins: ["192.168.1.64"], turbopack: {}, // Compression compress: true, // Image optimization images: { formats: ["image/avif", "image/webp"], remotePatterns: [ { protocol: "https", hostname: "habibapp.com", }, ], }, // Webpack config for data-locator injection in development webpack: (config, { dev }) => { if (dev) { config.module.rules.push({ test: /\.(tsx|jsx)$/, exclude: /node_modules/, use: [ { loader: path.resolve(__dirname, "src/plugins/jsx-locator-loader.cjs"), }, ], }); } return config; }, // Headers for caching and preload async headers() { return [ { // Never cache API proxy responses – always fetch fresh from backend source: "/api/:path*", headers: [ { key: "Cache-Control", value: "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0", }, { key: "Pragma", value: "no-cache", }, { key: "Expires", value: "0", }, ], }, { // Static pages – moderate cache source: "/:path((?!api/).*)", headers: [ { key: "Cache-Control", value: "public, max-age=3600, stale-while-revalidate=86400", }, ], }, { source: "/fonts/:path*", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, ]; }, }; export default nextConfig;