I´m having a CORS problem I´m not being able to fix. I´m loading images from a CDN and Phaser is not being able to load them, but a basic html in the same folder with an is loading them perfectly, so it´s not the CDN itself but the way I load them on Phaser.
What should I do? It´s the last thing I need to finish my app and it´s driving me crazy…
Access to XMLHttpRequest at 'https://cdn.*********.png?v=1.0' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The CDN server needs to allow origin, that is the origin (server address) that your app making this request has been served by, to make these requests from it.
The CDN is allowing that, I can load the same image in the same folder using an .html file and a tag, so it´s not server related.
LOL, whatever… why should I lie to you?
File is not loading in Phaser due to this but it´s loading in an html file, in the same localhost folder.
Basically, me doubting the truth in what you told does not necessarily mean you are lying or I mean it.
Apart from that check this docs page. It can be helpful.
Already tried that… same result.
I tried this way, not sure if it´s the right way…
this.load.setCORS(“anonymous”)
this.load.setCORS(“Anonymous”)
@totallybueno I have the same problem with Cordova.
CORS doesn’t apply to image tags in html documents, which is why the image would work via an <img />
tag.
If you are requesting the same resource, but via JavaScript, then you may run into CORS problems. In order for your code to be allowed to request that image, the server you are requesting it from needs to say it is okay. It says it’s okay by sending some headers back in the response to your request. Look at the network tab in the dev tools and see if there are any “Access-Control-“ headers in that response. If there are not, then the server is telling you that you aren’t allowed to load the resource and you’ll see a CORS error