Getting Issue in TextureLoader to Load Dynamic URL Getting CORs Error!

Hello, Greetings ! I am Getting CORs error in TextureLoader. I am calling AWS Image from API and try to Load but it is throwing CORs error and not passing any GET request to fetch Image to Load. but when I pass same AWS image URL in static string then it is loading perfectly fine. and I also try same code with different browser Like FireFox and Explore it is not showing any error it is working fine. only in Chrome it is showing an error and I also try with different version of Chrome to find is there any versioning issue but in all version it is giving same CORS error. Can anyone help me to identify where is the issue as I understood image is not loading due to issue in ImageLoader which is in three.js node-module. and I also check from Backend there allow-cross-origin ans allow-cross-origin-method is define as ‘*’.

const loader = new THREE.TextureLoader();

let StaticPath =
  'https://arbooks-3d-model.s3.us-west-2.amazonaws.com/chapter_images/1645113141.JPG?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAWSIFEYCA42XYTTHQ%2F20210122%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20210122T100618Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Signature=5bf61197f5389fd7873496514cd60b0c17f16642a8e30c9fd0603f0e67a4ce75';

const floorTexture = loader.load(ApiImg, (img) => {
  img.needsUpdate = true;
  img.crossOrigin = '';
  floor.scale.set(1.0, img.image.height / img.image.width, 1.0);
});

floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
const floorMaterial = new THREE.MeshBasicMaterial({
  map: floorTexture,
  side: THREE.DoubleSide,
});

const floorGeometry = new THREE.PlaneGeometry(1000, 1000, 10, 10);
floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.geometry.computeBoundingBox();
floor.geometry.needsUpdate = true;
const sizeOfMarker = floor.geometry.boundingBox.clone();
floor.position.y = -10;
floor.rotation.x = -Math.PI / 2;
scene.add(floor);![Screenshot from 2021-01-22 16-30-59|690x270](upload://4JQmJIFZFoXOtduDLZtaR6wf5tX.png) ![Screenshot from 2021-01-22 16-30-36|690x60](upload://ugyuTKY5k2ZaQ7Pei74PKIJ9dxI.png) ![Screenshot from 2021-01-22 16-30-15|690x233](upload://tcamgjWS01gqEAHx5HBueEdW96r.png) ![Screenshot from 2021-01-22 16-29-57|690x62](upload://d7WgRgY5ffM2mfO5XYh7Et7fMQf.png)

can anyone please help me ?

The response header in your second post have no CORS header.

access-control-allow-origin: *

So it seems you backend configuration is incomplete. You need at least the above entry.

I am getting same error

Have you solved this problem

Anyone found a resolution to this?

In all cases I have supported so far was the root cause the same: The above header missing in the HTTP response. This can only be fixed by updating the server configuration.

If you don’t know how to do that, this forum is the wrong place. Ask at the community of the respective server/cloud service.

1 Like

I have figured it out. The issue should be on chrome and safari but should work on firefox. Go through this blog it will work like a charm - Dealing with image CORS error in Chrome, Chromium and Edge

I wonder if something similar can be done by using some no-cache or similar flag when making the request, instead of faking a GET…