import type { NextConfig } from "next"; const securityHeaders = [ { key: 'X-DNS-Prefetch-Control', value: 'on' }, { key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubDomains; preload' }, { key: 'X-Frame-Options', value: 'SAMEORIGIN' }, { key: 'X-Content-Type-Options', value: 'nosniff' }, { key: 'Referrer-Policy', value: 'origin-when-cross-origin' }, { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' }, ]; const nextConfig: NextConfig = { images: { formats: ['image/avif', 'image/webp'], minimumCacheTTL: 31536000, localPatterns: [ { pathname: '/**', }, ], remotePatterns: [ { protocol: 'https', hostname: 'canina.ir', pathname: '/**', }, { protocol: 'https', hostname: 'api.canina.ir', pathname: '/**', }, { protocol: 'https', hostname: 'stage.canina.ir', pathname: '/**', }, { protocol: 'https', hostname: 'stageapi.canina.ir', pathname: '/**', }, { protocol: 'https', hostname: 'apicanina.parsaaghayi.ir', pathname: '/**', }, { protocol: 'https', hostname: 'canina.de', pathname: '/**', }, { protocol: 'https', hostname: 'www.canina.de', pathname: '/**', }, { protocol: 'https', hostname: 'images.unsplash.com', pathname: '/**', }, { protocol: 'https', hostname: 'plus.unsplash.com', pathname: '/**', }, { protocol: 'http', hostname: 'localhost', pathname: '/**', }, { protocol: 'http', hostname: '127.0.0.1', pathname: '/**', }, ], }, async headers() { return [ { source: '/:path*', headers: securityHeaders, }, ]; }, async rewrites() { // Only proxy /api in development; exclude local Next.js route handlers such as /api/revalidate if (process.env.NODE_ENV === 'development') { return [ { source: '/api/((?!revalidate).*)', destination: 'http://localhost:4001/api/$1', }, ]; } return []; }, }; export default nextConfig;