Page 1 of 1

Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Wed Dec 21, 2016 1:23 pm
by Grzesiek_R
I'm trying to embed a panorama created with Pano2VR on Moodle and it works in Firefox and Chrome but in Safari the player and skin load but the images don't, leaving a black screen and the web inspector gives me this error: Cross-origin image load denied by Cross-Origin Resource Sharing policy . I don't understand this since all the files including .html, .js, .xml and images folder are hosted on Moodle so I'm not pulling anything from other hosts. Also, what is weird is that this only happens when I use Version: 5.0.3 but when I use my older 3.1.4 version it's all ok.

Thanks for your help.

Greg

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Tue Dec 27, 2016 2:12 pm
by thomas
Hello Greg,

this is very odd. Can you please send me a link (as PM)? I tested CORS with Amazon S3 and for me this works as expected.

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Wed Dec 28, 2016 6:37 am
by Grzesiek_R
Hi Thomas

Unfortunately, I cannot send any links as our Moodle pages require a username and password. Is there anything else I can provide you with?

Also, where would I find the CORS configuration? Is it in the .xml or .js file?

Bw
Greg

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Tue Sep 19, 2017 5:08 pm
by DomC
OK, something of a late reply and hopefully will help others as it solved our issues with Safari browsers on the iMac, iPad and iPhones.
  • Find the 'pano2vr_player.js' code created by generating output
  • Open this .js file with a text editor (notepad will do)
  • Search for or find the term "crossOrigin"
About half way down in the block of code you should find/see this snippet of code:

Code: Select all

 this.crossOrigin="anonymous";
change it to:

Code: Select all

 this.crossOrigin=use-credentials";
I can't explain how or why very well, as I'm not that clever.. :? I think it's something to do with Safari seeking authenticity of the image(s) used.

Dom

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Wed Sep 20, 2017 7:47 am
by panox
Didn't you forget one quotation mark?

Code: Select all

 this.crossOrigin="use-credentials";

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Wed Sep 20, 2017 8:45 am
by DomC
panox wrote: Wed Sep 20, 2017 7:47 am Didn't you forget one quotation mark?

Code: Select all

 this.crossOrigin="use-credentials";
... thank you, yes, my error with the missing quote mark. Thanks for spotting that.

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Tue Oct 03, 2017 12:01 pm
by Grzesiek_R
Thanks a lot for your reply. I came up with the same idea but simply deleted that part of the code and it worked. However, changing it to 'use-credentials' also works!

Thanks

Re: Cross-origin image load denied by Cross-Origin Resource Sharing policy

Posted: Tue Oct 03, 2017 1:48 pm
by thomas
This method is a hack, but there is an API call that also survives a new player.

You can add the line

Code: Select all

pano.setCrossOrigin("use-credentials");
to the HTML page.

https://ggnome.com/doc/pano2vr/5/javascript-api/