// middlewares.ts
export default [
  'strapi::logger',
  'strapi::errors',
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': [
            "'self'",
            'data:',
            'blob:',
            'https://market-assets.strapi.io',
            'https://strapiblogcdkstack-media.s3.us-east-1.amazonaws.com', // Add your exact bucket URL
            '*.s3.us-east-1.amazonaws.com', // Add this for broader coverage
            `${process.env.CLOUDFRONT_URL || 'https://blog-media.genomii.ai'}` // Include CloudFront domain
          ],
          'media-src': [
            "'self'",
            'data:',
            'blob:',
            'https://market-assets.strapi.io',
            'https://strapiblogcdkstack-media.s3.us-east-1.amazonaws.com', // Add your exact bucket URL
            '*.s3.us-east-1.amazonaws.com', // Add this for broader coverage
            `${process.env.CLOUDFRONT_URL || 'https://blog-media.genomii.ai'}` // Include CloudFront domain
          ],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];