Cross-Origin-Resource-Sharing with Apache for a single file

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Cross-Origin-Resource-Sharing with Apache for a single file

Postby hansa » 20. September 2014 22:52

Hi,

I have an Appache Server (2.4) running on my machine, and would like to enable CORS for a certain file.

According to http://jerome.co.za/enabling-cross-origin-resource-sharing-aka-cors-in-apache/ I need to do something like the following i my httpd.conf:

Code: Select all
<Files "C:/xampp/htdocs/some/path/file.txt">
    Header set Access-Control-Allow-Origin "*"
</Files>


I have added this to my httpd.conf file, saved it, and restarted the server.

However, when trying to get this resource via ajax from a different network, I still get this issue:

XMLHttpRequest cannot load http://SERVERDNS.com/some/path/file.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.


How can I fix this? I am not sure if I put the tag in the correct place in httpd.conf, and also I am not sure about whether the Setting itself is done correctly.

I am running this server on a Windows Server 2012 machine on the Amazon Web Services EC2 cloud.

Can anyone shed some light onto this for me?

Thanks, best regards,

Chris
hansa
 
Posts: 2
Joined: 15. September 2014 08:50
Operating System: Windows Server 2012

Re: Cross-Origin-Resource-Sharing with Apache for a single f

Postby Nobbie » 21. September 2014 11:44

hansa wrote:According to http://jerome.co.za/enabling-cross-orig ... in-apache/ I need to do something like the following i my httpd.conf:

Code: Select all
<Files "C:/xampp/htdocs/some/path/file.txt">
    Header set Access-Control-Allow-Origin "*"
</Files>


You have to put these lines not SOMEWHERE in httpd.conf, it must be inside the VirtualHost of your SERVERDNS.com
Nobbie
 
Posts: 13177
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 153 guests