cancel
Showing results for 
Search instead for 
Did you mean: 
Go to solution

CORS file access errors

I need to access image files stored on my Godaddy shared-server cPanel/Linux site from another website on another server.   I get this error:

'from origin 'https://xyz.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://abc.com' that is not equal to the supplied origin.'

No matter what  'Header add Access-Control-Allow-Origin ...' directive I put in the .htaccess file in the /public_html directory, the directive seems to be ignored. It's like the .htaccess file is not being read. Or maybe it's being over ruled?

What do I need to do to get this working?

 

8 REPLIES 8
Super User III
Super User III

Re: CORS file access errors

@PoppyBill 

 

1) Just to confirm you are referring to the HTACCESS file on the shared server not the "target" server

2) can you provide the actual domains as so those in the community can see the errors ourselves to provide additional feedback



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: CORS file access errors

I don't know the difference between the shared server and the target server. 

Our main website is intowngallery.com which is built in WIX and is hosted on their servers. 

From a page on the main site I need to display images that are stored in the domain library.intowngallery.com which is hosted by Godaddy/cPanel on a shared linux server.

(That page is under development and is not yet available on the public site, so I am not sure how to let you see the actual error.)

The .htaccess file I am using is in public_html (the home directory for library.intowngallery.com).

(BTW because this is a shared server I do not have access to the Apache root.)

 

Super User III
Super User III

Re: CORS file access errors

@PoppyBill 

 

In your answer you did actually answer my question

 

library. is the shared and the wix is the target - I understand this isn't live yet- perhaps you can send me a direct message with a link to a single image or sample image so I can test from my side - 

 

I'd just like to confirm that it is cPanel causing the issue and not an issue with Wix blocking it



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: CORS file access errors

Thank you.

How do I send you a direct message?

I will send you html code you can test from any editor.

Super User III
Super User III

Re: CORS file access errors

@PoppyBill 

I just sent you a message



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: CORS file access errors

I sent you some html code with an embedded JS script which should show the problem.

It should run from any html editor. 

Note that you have to uncomment one of the four sample images before running.

BTW what is in the .htaccess file right now is just   Header add Access-Control-Allow-Origin "*"  but I have tried many other things.  

 

Also I am new to this so thank you for helping me through the process.

Super User III
Super User III
Solution

Re: CORS file access errors

@PoppyBill 

 

Thank you for send me your code - for those that might find this post - it looks to be an issue with Wix and they way they handle scripting

 

https://www.wix.com/corvid/forum/community-discussion/problem-with-access-control-allow-origin

 

Bill - if you can post an update after you've reviewed and let us know thanks



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Solution

Re: CORS file access errors

Problem solved!  PL281 is right that the problem lies with WIX.  However, the solution is surprising.

 

Background: I am using simply:  var sourceImage = new Image();   sourceImage.src=url;  in a script within an iFrame on a WIX page.  Note, however, that I need the uploaded image to not be tainted by CORS because I want to pass the image through  toDataURL() to get a temporary URL.

 

It turns out that in WIX upload does not allow some file names.  For example, WIX does not like '-Email' in the filename - remove it leaving the filename otherwise the same and the upload works fine.  Also WIX does not like 'screenshot' in the filename. There could be other exclusions as well, so if you are a WIX developer be warned.