Sanity CDN images not loading in Safari (production only) with next/image

5 replies
Last updated: Dec 1, 2025
I’m having loading issues on Safari as there seems to be a problem with recognizing the source link to the sanity content lake (in production only, localhost works fine). Below is the
<img/>
rendered (by next/image), check src:Any idea what’s causing the loading problem here? Why doesn’t Safari get the served image as an image file?


<img
  alt="Alt 1"
  src="/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=1920&q=100"
  decoding="async"
  data-nimg="responsive"
  style="position: absolute; inset: 0px; box-sizing: border-box; padding: 0px; border: none; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%;"
  sizes="100vw"
  srcset="/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=360&q=100 360w,
  /_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=768&q=100 768w,
  /_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=1024&q=100 1024w,
  /_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=1440&q=100 1440w,
  /_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Febplvzey%2Fproduction%2F89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg%3Fq%3D100&w=1920&q=100 1920w"
>

AI Update

This is most likely a Next.js configuration issue where cdn.sanity.io hasn't been properly added to your allowed image domains. The fact that it works on localhost but fails in production on Safari is a strong indicator of missing Next.js image optimization configuration.

When you use next/image with external image sources like Sanity's CDN, Next.js requires explicit configuration to allow those domains. Without this configuration, Next.js won't optimize the images properly, and browsers (particularly Safari) may fail to render them.

The primary solution is to configure your next.config.js:

For Next.js 12.3+ (recommended):

module.exports = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'cdn.sanity.io',
      },
    ],
  },
}

For older Next.js versions:

module.exports = {
  images: {
    domains: ['cdn.sanity.io'],
  },
}

After adding this configuration, you'll need to rebuild and redeploy your application.

Why this affects Safari specifically:

Safari tends to be more strict about content types and security policies than other browsers. When Next.js can't properly optimize the image due to missing domain configuration, it may serve the image in a way that Safari's security policies reject, while Chrome or Firefox might be more lenient. The localhost environment often bypasses some of these optimization checks, which is why you see different behavior between development and production.

Additional troubleshooting steps:

  1. Verify the image is accessible - Test the direct Sanity CDN URL (without Next.js's /_next/image wrapper) in Safari: https://cdn.sanity.io/images/ebplvzey/production/89d3576237a2b8840362eb811207e9d336137ed5-1200x630.jpg. If this loads fine, it confirms the issue is with Next.js configuration, not Sanity's CDN.

  2. Check your browser console - Look for any specific error messages in Safari's developer console that might provide more details about why the image isn't loading.

  3. Use Sanity's image URL builder - If you're not already using it, the @sanity/image-url helper library makes it easier to construct properly formatted Sanity image URLs. According to Sanity's Image Pipeline documentation, these URLs are designed to work seamlessly with modern frameworks like Next.js.

The remotePatterns (or domains) configuration is the standard requirement for using external image sources with Next.js Image component, and adding this should resolve your Safari loading issue in production.

Show original thread
5 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?