Reputation: 48899
Quote from Opera documentation (first link i've found):
Standard or custom headers are appropriate values for Access-Control-Allow-Headers. For the cross-origin request to succeed, its value must match (or include) the value of the Access-Control-Request-Headers header.
I'm sending a request using jQuery. If i comment out setRequestHeader
:
$(function() {
$.ajax({
url: 'http://silex.local/users',
method: 'GET',
beforeSend : function(req) {
//req.setRequestHeader('Authorization', 'FID ds7sd6:32n8942b3672n2');
}
});
});
It shouldn't work, since the server is responding with:
HTTP/1.0 200 OK
Date: Sat, 11 Aug 2012 02:15:14 GMT
Server: Apache/2.2.22 (Win32) PHP/5.3.14
X-Powered-By: PHP/5.3.14
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE
Access-Control-Allow-Headers: Authorization
Connection: close
Content-Type: application/json; charset=utf-8
While client is requesting with:
GET http://silex.local/users HTTP/1.1
Host: silex.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
Accept: */*
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Proxy-Connection: keep-alive
Referer: http://localhost/test.html
Origin: http://localhost
Cache-Control: max-age=0
What i'm missing? Sorry if this is an odd question, first time with CORS for me...
Upvotes: 1
Views: 3430
Reputation: 144912
I think you misunderstand what Access-Control-Allow-Headers
does (that poorly-worded quote doesn't help). It allows the server to tell the browser which headers are acceptable for cross-Origin XHR requests to set.
It does not mean that those headers are mandatory. If a script doesn't set a header, the request is still allowed to happen.
Upvotes: 5