import type { NextConfig } from "next"; import path from "path"; const nextConfig: NextConfig = { output: "standalone", poweredByHeader: false, reactStrictMode: true, allowedDevOrigins: ["192.168.1.64"], turbopack: {}, devIndicators: false, // Compression compress: true, // Image optimization for ultra-fast WebView media loading images: { formats: ["image/avif", "image/webp"], minimumCacheTTL: 31536000, 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; }, // Keep bookmarked links to the removed intermediate page functional. async redirects() { return [ { source: "/candidate-contact", destination: "/request-accepted", permanent: false, }, { source: "/:lang/candidate-contact", destination: "/:lang/request-accepted", permanent: false, }, ]; }, // 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", }, ], }, { // Application HTML pages – no-store to prevent HTML/shell caching in WebView source: "/:path((?!api/|_next/|fonts/|assets/).*)", headers: [ { key: "Cache-Control", value: "no-store, no-cache, must-revalidate, max-age=0", }, { key: "Pragma", value: "no-cache", }, ], }, { source: "/fonts/:path*", headers: [ { key: "Cache-Control", value: "public, max-age=31536000, immutable", }, ], }, { // Images and icons are not content-hashed, so revalidate instead of // pinning them for a year. source: "/assets/:path*", headers: [ { key: "Cache-Control", value: "public, max-age=86400, stale-while-revalidate=604800", }, ], }, ]; }, }; export default nextConfig;