I want to provide a cross domain service using POST. I can see preflight OPTIONS call successful, but when I post, the cookie is not sent in Chrome. The same javascript and server code work for Firefox and Safari. What could be the problem? Here are the details:
Request URL:http://j.test.com/Post
Request Method:OPTIONS
Status Code:200 OK
Request Headersview source
Accept:/
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, x-requested-with, content-type, accept
Access-Control-Request-Method:POST
Connection:keep-alive
Host:j.test.com
Origin:http://www.amazon.com
Referer:http://www.amazon.com/Gone-Girl-A-Novel-ebook/dp/B006LSZECO/ref=pd_rhf_gw_s_ts_2
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:origin, x-requested-with, content-type, accept
Access-Control-Allow-Methods:POST, OPTIONS
Access-Control-Allow-Origin:http://www.amazon.com
Access-Control-Max-Age:1728000
Connection:keep-alive
Content-Length:0
Date:Tue, 04 Sep 2012 16:44:48 GMT
Server:nginx
I use jQuery:
jQuery.ajax({
type: "POST",
url: "http://j.test.com/Post",
xhrFields: {
withCredentials: true
},
data: {
referringUrl: document.URL
},
success: function(data) {
},
error: function (responseData, textStatus, errorThrown) {
}
});