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

Q&A about the latest versions
Post Reply
Grzesiek_R
Posts: 11
Joined: Wed Dec 21, 2016 11:48 am

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
User avatar
thomas
Chief Gnome
Posts: 2611
Joined: Fri Sep 01, 2006 3:56 pm
Location: Vienna, Austria
Contact:

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.
MfG, Thomas
Grzesiek_R
Posts: 11
Joined: Wed Dec 21, 2016 11:48 am

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
User avatar
DomC
Posts: 7
Joined: Tue Sep 19, 2017 3:25 pm

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
User avatar
panox
Posts: 305
Joined: Mon Mar 12, 2007 11:03 pm
Contact:

Didn't you forget one quotation mark?

Code: Select all

 this.crossOrigin="use-credentials";
User avatar
DomC
Posts: 7
Joined: Tue Sep 19, 2017 3:25 pm

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.
Grzesiek_R
Posts: 11
Joined: Wed Dec 21, 2016 11:48 am

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
User avatar
thomas
Chief Gnome
Posts: 2611
Joined: Fri Sep 01, 2006 3:56 pm
Location: Vienna, Austria
Contact:

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/
MfG, Thomas
Post Reply