REJH
REJH

Reputation: 3275

Access-Control-Allow-Origin: * is set but I still get Origin not allowed

I'm working on a web client that reads a JSON file from a remote server using jQuery. And I'm having trouble getting it to work.

Code:

jQuery.getJSON('http://[remote-ip]/openbeacon/test.json', updateJsonCallback);

Error:

XMLHttpRequest cannot load http://[remote-ip]/openbeacon/test.json.
Origin http://[remote-ip] is not allowed by Access-Control-Allow-Origin.

I've read up on the whole Access-Control-Allow-Origin thing and thought I had found the solution: Add 'Header set Access-Control-Allow-Origin "*"' to the Apache config file (httpd.conf) and restart the service. Unfortunately this didn't work.

I checked the header: the options does show up now - but Chrome still won't let me have access. I even compared the header to that of a json file that does work remotely:

http://api.openbeacon.net/get/brucon.json < WORKS

HTTP/1.1 200 OK
Date: Tue, 20 Nov 2012 15:01:43 GMT
Server: Apache
Last-Modified: Tue, 20 Nov 2012 15:01:43 GMT
ETag: W/"d073949-154d-4ceee830cdae1"
Accept-Ranges: bytes
Content-Length: 5453
Access-Control-Allow-Origin: *
Connection: close
Content-Type: application/json; charset=utf-8

http://[remote-ip]/openbeacon/test.json < DOES NOT WORK

HTTP/1.1 200 OK
Date: Tue, 20 Nov 2012 15:01:41 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1
Last-Modified: Tue, 20 Nov 2012 15:01:41 GMT
ETag: W/"2b8ab16-1e7-4ceee82edbf40"
Accept-Ranges: bytes
Content-Length: 487
Acces-Control-Allow-Origin: *
Connection: close
Content-Type: application/json

Help?

Upvotes: 3

Views: 3623

Answers (1)

REJH
REJH

Reputation: 3275

Okay this was pretty stupid. As @Rocket already pointed out I mistyped Access. Sigh.

Acces-Control-Allow-Origin: *

Should be

Access-Control-Allow-Origin: *

Upvotes: 3

Related Questions