CORS error on PlayCanvas hosted assets

I just tried publishing my prototype on Playcanvas to test, and I’m getting a CORS error when trying to manipulate some data on a separate canvas (I use it to build an opacity map for my 2D ray-casting), it says the canvas has been tainted by cross-origin data.

The assets are stored inside PlayCanvas, and I used Asset.getFileUrl() to get the correct URL which I then load to an in-memory image tag, and thus to a canvas.

Looking at the headers, the data coming back from Amazon S3 doesn’t have any CORS headers, although I’m confused because I swear this was working last night… but since I don’t have control over the S3 bucket, do I need to do things a different way, or is it possible to add CORS headers there?

Are you mixing http and https sources/assets?

No, It’s actually a CORS issue - no CORS headers on the downloaded asset…


Actually, I was being stupid! I had no need to download the asset again, because:

asset.resource.texture.getSource() is an HTMLImageElement! So I was able to cut out the extra download, and just use that as a source for my in-memory canvas, and voila! :slight_smile: