Sanity
Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

TextureLoader Error: "Access to Image at 'https://mydomain.com>' Has Been Blocked by CORS Policy"

3 replies
Last updated: Aug 11, 2021

Does anyone encountered problem when fetching images via JS such like TextureLoader from threejs? I constantly get errors of cors also if my domain is enabled. The strange thing is that the error said that the origin is the localhost domain:

Access to image at '<https://cdn.sanity.io/images/*****/development/1e97591658bd9baa39647acbccd6a098c2e30c38-1400x1400.jpg?auto=format>' from origin '<https://mydomain.com>' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value '<http://localhost:3000>' that is not equal to the supplied origin.

Jul 30, 2021, 10:30 AM

it's strange because it's pretty usual that you have more than one cors domain and it will resolve always as a random one (it switch frequently from localhost to production) making a cache bursting param works.

Jul 30, 2021, 4:15 PM

The problem is now showing again.

Aug 11, 2021, 7:46 AM

It's very random, somethimes works somethimes not

Aug 11, 2021, 7:46 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.