Can anyone help me up with textureLoader configuration? I would like to load an youtube video thumbnail and I’m not sure how to add the minimum requested headers to textureLoader in order to prevent CORS from trowing an error.
Unfortunately the Access-Control-Allow-Origin header cannot be set by JavaScript on the web page — it’s the YouTube server that would need to allow requests from all origins, and it doesn’t appear to do so. A few more details on CORS that may be helpful:
You can request permission to load a cross-origin image with:
textureLoader.crossOrigin = 'anonymous';
However, this is already the default, and whether any given remote server accepts that request is up to that server. If it doesn’t, the browser will not give the web page access to the image.
Thank you for your response. If I’m using localhost or the http protocol for both server and youtube URL, the image is loaded properly; now, accessing an unsecured url from a secured server is not allowed, the requested url will be automatically converted to https and then we get the cors problem… it’s there a way to trick this, to access http from https?