import type { NextConfig } from "next";
import createNextIntlPlugin from 'next-intl/plugin';

const withNextIntl = createNextIntlPlugin();

const nextConfig: NextConfig = {
  // This repository has a second lockfile at its root. Explicitly keeping
  // Turbopack inside the frontend prevents route discovery from using the
  // wrong workspace during local development.
  turbopack: {
    root: __dirname,
  },
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'picsum.photos',
      },
      {
        protocol: 'https',
        hostname: 'images.unsplash.com',
      },
      // MinIO runs locally during development and serves the product images
      // uploaded by sellers. Keep the bucket private for inventory files;
      // this only permits product-image URLs rendered by next/image.
      {
        protocol: 'http',
        hostname: 'localhost',
        port: '9000',
      },
      // Product images now go through the backend public-image endpoint so
      // the storage bucket does not need to expose every object publicly.
      {
        protocol: 'http',
        hostname: 'localhost',
        port: '8080',
        pathname: '/api/upload/public/**',
      },
      // Support the same local backend when it is addressed by IP instead of
      // localhost (for example from another browser profile or device).
      {
        protocol: 'http',
        hostname: '127.0.0.1',
        port: '8080',
        pathname: '/api/upload/public/**',
      },
    ],
  },
};

export default withNextIntl(nextConfig);
