/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'standalone',
  skipTrailingSlashRedirect: true,
  images: {
    unoptimized: false,
    domains: ['www.qrmaster.net', 'qrmaster.net', 'images.qrmaster.net'],
    formats: ['image/webp', 'image/avif'],
    deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
    imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
  },
  experimental: {
    serverComponentsExternalPackages: ['@prisma/client', 'bcryptjs'],
  },
  // Allow build to succeed even with prerender errors
  // Pages with useSearchParams() will be rendered dynamically at runtime
  staticPageGenerationTimeout: 120,
  onDemandEntries: {
    maxInactiveAge: 25 * 1000,
    pagesBufferLength: 2,
  },
  poweredByHeader: false,
  async redirects() {
    return [
      {
        source: '/create-qr',
        destination: '/dynamic-qr-code-generator',
        permanent: true,
      },
      {
        source: '/guide/tracking-analytics',
        destination: '/learn/tracking',
        permanent: true,
      },
      {
        source: '/guide/bulk-qr-code-generation',
        destination: '/learn/developer',
        permanent: true,
      },
      {
        source: '/guide/qr-code-best-practices',
        destination: '/learn/basics',
        permanent: true,
      },
      {
        source: '/tools/phone-qr-code',
        destination: '/tools/call-qr-code-generator',
        permanent: true,
      },
      {
        source: '/barcode-generator',
        destination: '/tools/barcode-generator',
        permanent: true,
      },
      {
        source: '/bar-code-generator',
        destination: '/tools/barcode-generator',
        permanent: true,
      },
      {
        source: '/qr-code-for/breweries-tap-rooms',
        destination: '/qr-code-for/breweries',
        permanent: true,
      },
      {
        source: '/qr-code-for/wineries-vineyards',
        destination: '/qr-code-for/wineries',
        permanent: true,
      },
      {
        source: '/qr-code-for/catering-businesses',
        destination: '/qr-code-for/catering',
        permanent: true,
      },
      {
        source: '/qr-code-for/spas-wellness-centers',
        destination: '/qr-code-for/spas',
        permanent: true,
      },
      // Additional likely old slugs from previous site version
      { source: '/qr-code-for/bars-pubs', destination: '/qr-code-for/bars', permanent: true },
      { source: '/qr-code-for/nightclubs-venues', destination: '/qr-code-for/nightclubs', permanent: true },
      { source: '/qr-code-for/dental-practices', destination: '/qr-code-for/dentists', permanent: true },
      { source: '/qr-code-for/pet-groomers', destination: '/qr-code-for/pet-grooming', permanent: true },
      { source: '/qr-code-for/clothing-apparel-stores', destination: '/qr-code-for/clothing-stores', permanent: true },
      { source: '/qr-code-for/florists-flower-shops', destination: '/qr-code-for/florists', permanent: true },
      { source: '/qr-code-for/pet-stores-groomers', destination: '/qr-code-for/pet-stores', permanent: true },
      { source: '/qr-code-for/hardware-diy-stores', destination: '/qr-code-for/hardware-stores', permanent: true },
      { source: '/qr-code-for/universities-colleges', destination: '/qr-code-for/universities', permanent: true },
      { source: '/qr-code-for/museums-exhibitions', destination: '/qr-code-for/museums', permanent: true },
      { source: '/qr-code-for/public-libraries', destination: '/qr-code-for/libraries', permanent: true },
      { source: '/qr-code-for/theaters-performing-arts', destination: '/qr-code-for/theaters', permanent: true },
      { source: '/qr-code-for/cinemas-movie-theaters', destination: '/qr-code-for/cinemas', permanent: true },
      { source: '/qr-code-for/churches-places-of-worship', destination: '/qr-code-for/churches', permanent: true },
      { source: '/qr-code-for/stadiums-sports-venues', destination: '/qr-code-for/stadiums', permanent: true },
      { source: '/qr-code-for/airports-travel-hubs', destination: '/qr-code-for/airports', permanent: true },
      { source: '/qr-code-for/photography-studios', destination: '/qr-code-for/photographers', permanent: true },
      { source: '/qr-code-for/trade-shows-exhibitions', destination: '/qr-code-for/trade-shows', permanent: true },
      { source: '/qr-code-for/accounting-firms', destination: '/qr-code-for/accountants', permanent: true },
    ];
  },
};

export default nextConfig;
